Mobile Assistant

Mobile Assistant

Source code introduction

Similar to 360 mobile assistant
Source code screenshot

[[131148]]

Source code snippet:

  1. public   class FlashWidgetService extends Service {
  2. private ApwReciver apReciver; // appwidget broadcast  
  3. Camera mCamera;
  4. Camera.Parameters parameters;
  5. private   boolean blag = false ; // Control variable used to update the flash status  
  6.   
  7. @Override  
  8. public IBinder onBind(Intent arg0) {
  9. return   null ;
  10. }
  11.   
  12. @SuppressLint ( "NewApi" )
  13. @Override  
  14. public   void onCreate() {
  15. // Broadcast Receiver  
  16. apReciver = new ApwReciver();
  17. // Get the Camera object  
  18. mCamera = Camera.open( 0 );
  19. parameters = mCamera.getParameters();
  20. super .onCreate();
  21. }
  22.   
  23. @Override  
  24. public   void onStart(Intent intent, int startId) {
  25. // Register appwidget broadcast  
  26. IntentFilter intentFilter = new IntentFilter();
  27. intentFilter.addAction(FlashWidgetProvider.OPEN_ACTION); //  
  28. intentFilter.addAction(FlashWidgetProvider.ISOPEN_ACTION);
  29. intentFilter.addAction(FlashWidgetProvider.ISCLOSE_ACTION);
  30. registerReceiver(apReciver, intentFilter);
  31. super .onStart(intent, startId);
  32. }
  33.   
  34. @Override  
  35. public   void onDestroy() {
  36.           
  37. if (mCamera != null ) {
  38. mCamera.release();
  39. }
  40. }
  41.   
  42. public   class ApwReciver extends BroadcastReceiver {
  43. @Override  
  44. public   void onReceive(Context context, Intent intent) {
  45.   
  46. if (intent.getAction().equals(FlashWidgetProvider.OPEN_ACTION)) {
  47. if (blag == false ) { // Not opened  
  48. // Turn on the flash  
  49. parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
  50. mCamera.setParameters(parameters);
  51. // Send a broadcast, receive it in AppWidget, and change the flashlight image  
  52. sendBroadcast( new Intent(FlashWidgetProvider.ISOPEN_ACTION));
  53. blag = true ;
  54. } else   if (blag == true ) { // Opened  
  55. // Turn off the flash  
  56. parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
  57. mCamera.setParameters(parameters);
  58. sendBroadcast( new Intent(FlashWidgetProvider.ISCLOSE_ACTION));
  59. blag = false ;
  60. }
  61.   
  62. }
  63.   
  64. }
  65.   
  66. }
  67. }

Source code link: http://download..com/data/2015699

<<:  Query traffic information

>>:  Android is everywhere and invading Windows

Recommend

Tu Ma "Hot Copywriting" Hard-core Special Forces Incubation Camp

The course comes from the popular copywriting har...

B station's brand marketing routine

Bilibili was once considered a non-mainstream vid...

The crux of virtual reality content: what is missing besides technology

Unlike the underlying hardware and software, ther...

After watching 1,000 videos, we summarized 10 ways to make money on Douyin!

In the past two days, I have watched more than 1,...

Global Science News | List of Highly Cited Scholars in 2021 Announced

· the scientist· Clarivate Analytics announces 20...

Analysis of the "Fan Deng Reading" activity

The case analysis brought to you today is Fan Den...

Seeding + live streaming, a complete guide to playing Douyin on Double Eleven

The annual Double Eleven Carnival is about to beg...