I am trying to get my Android app to start automatically on boot up. I have followed various examples and copied the code, but still, when I power up, the app does NOT start.
I am using a Galaxy Tab A7 Lite, running Android 11.
Any help gladly received.
Thank you.
Here is my code...
I have defined the receiver:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class StartOnBootupReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent activityIntent = new Intent(context, MainActivity.class);
context.startActivity(activityIntent);
}
}
}
And in the AndroidManifest.xml file:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and
<receiver android:name=".StartOnBootupReceiver"
android:exported="false"
>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action..QUICKBOOT_POWERON" />
</intent-filter>
</receiver>