Application startup:
If you need to quickly access your own application after booting up, you can click Android Manifest Static registration of system startup broadcast in xml, and
In the onReceive method, we start the main activity of the application. Our system does not limit the startup behavior of the application. The reference method is as follows:
<receiver
android:name=".BootBroadcastReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter android:priority="1000”>//Increase broadcast priority
<!--.Receive the broadcast completed by startup-->
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
private static final String ACTION_BOOT = "android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_BOOT)) { //What to do after startup
Log.d("BootBroadcastReceiver", "BootBroadcastReceiver onReceive(), Do thing!");
Intent playIntent = new Intent(context, MainActivity.class);
playIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(playIntent);
}
}
Tips:After the application is installed, it needs to be started manually once to realize automatic startup after the next boot.