We know that the method of enabling startup in Android registers a static broadcast to listen to the broadcast that has been booted, and then after receiving the boot broadcast, the method of starting Activity or Service, is as follows:
first, create a new broadcast listener to listen to the broadcast that has been booted
public class BootCompletedReceiver extends BroadcastReceiver {
private static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(action_boot)){
Intent intent=new Intent(context,MainActivity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
}
then, statically register the broadcast with AndroidManifest.xml
<receiver android:name=".BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
finally, apply for permission in AndroidManifest.xml
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
it is possible to enable and launch APP, through the above methods. However, there is a problem with this method. The above methods must manually run APP after installing APP before APP can receive android.intent.action.BOOT_COMPLETED
broadcasts.
if APP has no Activity, only Service, or cannot be run manually after installation, and the Service or Activity, of this APP cannot be started through other APP, how can it be started after installation? What methods does PS: have on the basis that it can modify the Android system code?