如何在手机重启时自动重启Android应用程序。 我为Android制作了一个应用程序,现在我希望它会在重新启动手机时自动重启 ,任何人都可以帮助我。?
答案 0 :(得分:0)
您可以使用BroadcastReceiver侦听BOOT_COMPLETED广播并执行您想要的操作。
答案 1 :(得分:0)
<receiver android:name=".BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
答案 2 :(得分:0)
来自http://www.anddev.org/launch_activity_on_system-emulator_startup-t428.html
在清单
中 <receiver class=".MyStartupIntentReceiver">
<intent-filter>
<action android:value="android.intent.action.BOOT_COMPLETED" />
<category android:value="android.intent.category.HOME" />
</intent-filter>
</receiver>
MyStartupIntentReceiver-Class:
public class MyStartupIntentReceiver extends IntentReceiver {
@Override
public void onReceiveIntent(Context context, Intent intent) {
/* Create intent which will finally start the Main-Activity. */
Intent myStarterIntent = new Intent(context, LaunchOnStartup.class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
/* Send the Intent to the OS. */
context.startActivity(myStarterIntent);
}
}