Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

 

Show the video description

In this video we will learn how to automatically start an activity when we boot up the device, by registering a BOOT_COMPLETED broadcast receiver and starting a new intent in it’s onReceive method.
On this intent we have to set the FLAG_ACTIVITY_NEW_TASK because we want to call startActivity from outside of an activity context.
To receive the boot broadcasts we have to add the RECEIVE_BOOT_COMPLETED permission into the manifest file.
On some devices, BOOT_COMPLETED will not be triggered when the device gets restarted, so we will also add the QUICKBOOT_POWERON intent filter.

StartActivityOnBootReceiver.javaAndroidManifest.xml