猿问

安装后如何永久运行应用程序?

我想在安装后在后台运行我的 android 应用程序。我试着在后台运行应用程序。但是我必须在重新启动设备后自己启动应用程序。我需要的是我需要像 FACEBOOK 一样使用我的应用程序,whatsapp 正在做。据我所知,它们永远在后台运行,每次重启后都不需要手动重启。有人来帮助我吗?


慕森王
浏览 149回答 2
2回答

侃侃无极

在 AndroidManifest.xml 中<receiver android:name=".BootUpReceiver">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <intent-filter>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <action android:name="android.intent.action.BOOT_COMPLETED" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </intent-filter>&nbsp; &nbsp; &nbsp; &nbsp; </receiver>创建以 BootUpReceiver 命名的 Java 文件public class BootUpReceiver extends BroadcastReceiver {&nbsp; &nbsp; @Override&nbsp; &nbsp; public void onReceive(Context context, Intent intent) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Do your coding here...&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; }}
随时随地看视频慕课网APP

相关分类

Java
我要回答