如何在手机开机时自动运行应用程序

时间:2010-07-28 13:30:15

标签: android android-activity autorun

任何人都可以给我自动在Android设备上运行Android应用程序的代码或链接或概念..无论何时打开设备,应用程序都应该自行启动,不受用户的干扰。

谢谢..

1 个答案:

答案 0 :(得分:4)

您需要声明一个侦听RECEIVE_BOOT_COMPLETED的广播侦听器

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

在你的听众中:

Intent myStarterIntent = new Intent(context, YOUR_CLASS_TO_START.class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
/* Send the Intent to the OS. */
context.startActivity(myStarterIntent);

使用上述想法的另一个例子:auto start app

相关问题