[英]Setting an app to launch after every reboot
Ideally, we want our app to be the first one to get launched after every reboot, it is a system app so can we set it as default through code?理想情况下,我们希望我们的应用程序在每次重启后第一个启动,它是一个系统应用程序,所以我们可以通过代码将其设置为默认值吗?
best you can do is BOOT_COMPLETED
handling你能做的最好的就是BOOT_COMPLETED
处理
manifest显现
<receiver
android:name="custom.package.BootReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Java side Java侧
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
// your code
}
}
}
but I'm afraid that with this approach you can never be sure if it will be called at first.但恐怕用这种方法你永远无法确定它是否会被调用。 And I know one "kind" of apps that will be called/opened earlier that any app will receive above broadast - devices Launcher而且我知道一种“类型”的应用程序将更早地被调用/打开,任何应用程序都将在广播之上接收 - 设备启动器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.