SoFunction
Updated on 2025-03-04

Android application automatic startup method

Principle: The Android system will send a broadcast when it is turned on. This way we can receive this broadcast and then launch our application. The broadcast receiver must be configured in the XML, because the broadcast receiver configured in the XML does not exit with the application exit.

Broadcast receiver:

package ;

import ;
import ;
import ;

public class BootReceiver extends BroadcastReceiver {
 @Override
 public void onReceive(Context context, Intent intent) {
 Intent i = new Intent(context, );
 // This must add flags (Intent.FLAG_ACTIVITY_NEW_TASK);
 (i);
 }
}

In the implementation of the application tag:

  <!-- Start up -->
 <receiver android:name="">
 <intent-filter>
  <action android:name=".BOOT_COMPLETED"/>
  <category android:name=""/>
 </intent-filter>
 </receiver>

Add permissions:

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

That's all.
I used Redmi Note to test it, and I need to worry about setting it up:
Click Settings 》Applications》 Find your application》Click to pull to the bottom of the permission management》Automatically start》 Complete.