How to Start an Application at Device Bootup in Android

nilan avtar
Nilanchala Panigrahy 🌱

This tutorial will explain to stat an application while the Android device boot-up. For this we need to  listen to the BOOT_COMPLETED action and react to it. BOOT_COMPLETED is a Broadcast Action that is broadcast once, after the system has finished booting. You can listen to this action by creating a BroadcastReceiver that then starts your launch Activity when it receives an intent with the BOOT_COMPLETED action.

1. Add this permission to your manifest:

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

How to Start an Application at Device Bootup in Android

2. Create a Custom BroadcastReceiver in your project to receive boot up event

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver{

	public void onReceive(Context context, Intent intent) {
		Intent i = new Intent(context, MainActivity.class);  

3. Adding the BroadCastReceiver to the Android Manifest

android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />

Install the application, and then restart the device. You can see the application will start after the device restarts.

Sharing is caring!

Did you like what Nilanchala Panigrahy 🌱 wrote? Thank them for their work by sharing it on social media.

nilan avtar

Nilanchala Panigrahy 🌱

I'm a blogger, educator and a full stack developer. Mainly focused on Java, Spring and Micro-service architecture. I love to learn, code, make and break things.

Related articles