av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Android開機(jī)自啟動(dòng)具體操作方法簡介

在模擬器中對(duì)Android 操作系統(tǒng)進(jìn)行相應(yīng)的編寫,可以幫助我們實(shí)現(xiàn)應(yīng)用程序的開機(jī)自啟動(dòng)功能。在這里我們就來通過一段代碼充分的掌握Android開機(jī)自啟動(dòng)的相關(guān)實(shí)現(xiàn)方法,以幫助大家掌握這一應(yīng)用。

1.定義一個(gè)BroadcastReceiver

Java代碼

 
 
 
  1. public class BootReceiver extends BroadcastReceiver {   
  2. public void onReceive(Context ctx, Intent intent) {   
  3. Log.d("BootReceiver", "system boot completed");   
  4. //start activity   
  5. String action="android.intent.action.MAIN";   
  6. String category="android.intent.category.LAUNCHER";   
  7. Intent myi=new Intent(ctx,CustomDialog.class);   
  8. myi.setAction(action);   
  9. myi.addCategory(category);   
  10. myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
  11. ctx.startActivity(myi);   
  12. //start service   
  13. Intent s=new Intent(ctx,MyService.class);   
  14. ctx.startService(s);   
  15. }   
  16. }   
  17. public class BootReceiver extends BroadcastReceiver {  
  18. public void onReceive(Context ctx, Intent intent) {  
  19. Log.d("BootReceiver", "system boot completed");  
  20. //start activity  
  21. String action="android.intent.action.MAIN";  
  22. String category="android.intent.category.LAUNCHER";  
  23. Intent myi=new Intent(ctx,CustomDialog.class);  
  24. myi.setAction(action);  
  25. myi.addCategory(category);  
  26. myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
  27. ctx.startActivity(myi);  
  28. //start service  
  29. Intent s=new Intent(ctx,MyService.class);  
  30. ctx.startService(s);  
  31. }  

2.配置Receiver的許可,允許接收系統(tǒng)啟動(dòng)消息,在AndroidManifest.xml中:

Xml代碼

 
 
 
  1. < uses-permission android:name=
    "android.permission.RECEIVE_BOOT_COMPLETED"/>   
  2. < uses-permission android:name=
    "android.permission.RECEIVE_BOOT_COMPLETED"/> 

3.配置Receiver,可以接收系統(tǒng)啟動(dòng)消息,在AndroidManifest.xml中

Android開機(jī)自啟動(dòng)的Xml代碼

 
 
 
  1. < receiver android:name=".app.BootReceiver">   
  2. < intent-filter>   
  3. < action android:name="android.intent.action.BOOT_COMPLETED"/>   
  4. < category android:name="android.intent.category.HOME" />   
  5. < /intent-filter>   
  6. < /receiver>   
  7. < receiver android:name=".app.BootReceiver"> 
  8. < intent-filter> 
  9. < action android:name="android.intent.action.BOOT_COMPLETED"/> 
  10. < category android:name="android.intent.category.HOME" /> 
  11. < /intent-filter> 
  12. < /receiver> 

4.啟動(dòng)模擬器,可以看到系統(tǒng)啟動(dòng)后,彈出一個(gè)對(duì)話框。

Android開機(jī)自啟動(dòng)的具體方法就為大家介紹到這里。

【編輯推薦】

  1. Android顯示網(wǎng)絡(luò)圖片相關(guān)實(shí)現(xiàn)方法淺談 
  2. Android應(yīng)用技巧總結(jié) 
  3. Android Theme詳細(xì)內(nèi)容概述 
  4. Android重力感應(yīng)實(shí)現(xiàn)方式簡介 
  5. Android HelloWord編寫方式介紹 

網(wǎng)站欄目:Android開機(jī)自啟動(dòng)具體操作方法簡介
網(wǎng)站鏈接:http://uogjgqi.cn/article/cdideos.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流