How to authorize the application when the phone is turned on

Can someone please give me the code or links or concept for launching android application on android device automatically. whenever the device is turned on, the application should start independently, without user intervention.

Thank..

+3
source share
1 answer

You need to declare a broadcast listener that is listening on RECEIVE_BOOT_COMPLETED

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

In your listener:

Intent myStarterIntent = new Intent(context, YOUR_CLASS_TO_START.class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
/* Send the Intent to the OS. */
context.startActivity(myStarterIntent);

another example using the above ideas: an autorun application

+4
source

Source: https://habr.com/ru/post/1756941/


All Articles