When an android phone is completed turned on (booted), an intent is broadcated:
Try this BootReceiver class
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context aContext, Intent aIntent) {
// if (BOOT_ACTION_NAME.equals(intent.getAction())) {
// ToDo: Whatever I need at immediately after bootstrap
Toast.makeText(aContext, "This message phone is turned on!", Toast.LENGTH_LONG).show();
Log.e("..BOOT_ACTION_NAME...", "This message phone is turned on!");
// }
}}
add to below class in manifest.xml in application tag
<receiver
android:name="com.example.testing_demo.BootReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>