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

10 WeChat Moments Ads to Understand the Keyword Marketing in 2020

Advertising can also be a part of life”, this was...

5 common marketing mistakes!

If you are a marketing planner, don’t you hope th...

How to set keywords for Xiaohongshu promotion notes!

On the Xiaohongshu platform, taking good notes is...

Metallic hydrogen is about to be "ruined"

Hydrogen is the most abundant element in the univ...

Big Data and Behavior Prediction Model—Liu Zhijun

Today I want to talk to you about big data and ac...

Naixue-P8 Million Big Data Architect Phase I

Naixue-P8 Million Big Data Architect Phase I Reso...

Which SEO training is best? Which SEO technical training is the best?

For many friends who are new to the SEO industry,...