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”


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded