[Java] Android在启动时自动运行应用程序 →→→→→进入此内容的聊天室

来自 , 2021-04-21, 写在 Java, 查看 164 次.
URL http://www.code666.cn/view/f23b3df7
  1. in AndroidManifest.xml (application-part):
  2.  
  3. <receiver android:enabled="true" android:name=".BootUpReceiver"
  4.         android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
  5.  
  6.         <intent-filter>
  7.                 <action android:name="android.intent.action.BOOT_COMPLETED" />
  8.                 <category android:name="android.intent.category.DEFAULT" />
  9.         </intent-filter>
  10. </receiver>
  11. [..]
  12. <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  13. [..]
  14.  
  15. public class BootUpReceiver extends BroadcastReceiver{
  16.  
  17.         @Override
  18.         public void onReceive(Context context, Intent intent) {
  19.                 Intent i = new Intent(context, MyActivity.class);  
  20.                 i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  21.                 context.startActivity(i);  
  22.         }
  23.  
  24. }
  25. //java/5503

回复 "Android在启动时自动运行应用程序"

这儿你可以回复上面这条便签

captcha