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

It’s orange season again! Which one is your favorite?

As autumn deepens, a large number of oranges are ...

Year-end review: Interpretation of the top ten domestic technology news in 2021

The year of 2021, with its climaxes one after ano...

How much does it cost to make a small program?

It is estimated that many people do not know much...

How do fish avoid danger? What are some ways to defend against enemies?

Produced by: Science Popularization China Author:...

The iOS system has updated these things. Do you think they are great?

The official version of OS15 is finally here. Wha...

2 pictures to help you understand Toutiao's recommendation system

The “predecessors” of recommendation systems In 2...

Is standing at work healthier than sitting? This result is really unexpected...

Compiled by: Gong Zixin In recent years With the ...