How to send BOOT COMPLETED Intent / How to simulate boot complete intent order ?

When Android is booting ( Or you powered ON android first time or rebooted ), and when it has completed booting, Android sends a broadcast intent BOOT_COMPLETED to let all the applications, services know that now everything is setup and android booting has been completed, so we can start any other services , applications.

If our package name is com.android.TestService and Broadcast receiver intent is com.android.TestBroadcastReceiver

use below command to send boot completed intent manually from adb shell,

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n com.android.TestService/com.android.TestService.TestBroadcastReceiver 

Refer code like below from AndroidManifest.xml to identify name of Broadcast receiver,

<receiver android:name="com.android.TestBroadcastReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

And the TestBroadcastReceiver class needs to defined as,

package com.android.TestService;

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

public class TestBroadcastReceiver extends BroadcastReceiver {
    public static final String TAG = "TestService:TestBroadcastReceiver";

    @Override
    public void onReceive(final Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
            Log.d(TAG, "onReceive: boot completed");
        }
    }

}

If you want to know, how this code can be used to receive an On Boot complete intent, you can refer to “Understanding Android Services with Example”

Leave a Comment