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

Douyin monetization 2020, quickly create a profitable Douyin

Whether it is operating a full-platform self-medi...

CCS Insight: Mobile phone shipments in 2020 will be the lowest in a decade

2020 is going to be tough for phone makers, with ...

How will Youpengpule start its three engines with 2 billion yuan in hand?

In the Internet TV industry, Youpengpule is consi...

How to promote and operate Xiaohongshu? Xiaohongshu promotion tips!

Not long ago, the news about Xiaohongshu conducti...

Tik Tok Operation Data Analysis Skills

Before we create a Douyin account, we must find a...

Yima SEO Training: How to build high-quality website external links?

When checking keyword rankings during website opt...

Xinyu SEO training: Reasons why Baidu snapshots show blank and no content

I found that someone raised the issue of Baidu sn...