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

Li Liheng Everyone is a Sales Champion Course

Course Description: Li Liheng 10-year veteran in ...

Without bicycles, we can't even take a plane!

June 3rd of each year is World Bicycle Day. The b...

How much does it cost to customize the Chengde housekeeping mini program?

There is no fixed price for the customization of ...

Learn the best practices of modern Android development in one article

Author: Wang Peng, Sun Yongsheng What is MAD? ​​h...

Google may force Android phones to encrypt in the future

Lollipop system encryption options According to f...

Wei Chunyang: Practical Course on Institutional Trading Codes (February 2022)

Wei Chunyang: Practical Course on Institutional T...

12 channels for selling goods through live streaming!

Previously, I shared with you how to build a circ...

B station community operation model!

As a relatively mature community platform in Chin...

Boss Dai from Fantong: "Yuanchuan Investment Academy"

Boss Dai from Fantong: "Yuanchuan Investment...

Is the iPad Pro 2020 good to use? Let's see what foreign media reviews say

The iPad Pro 2020 models have been delivered to u...