BroadcastReceiver not receiving BOOT_COMPLETED

apmeyers1987 picture apmeyers1987 · Feb 19, 2011 · Viewed 96.6k times · Source

I've looked around here for similiar problems, but for some reason my BroadcastReceiver never ends up receiving the android.intent.action.BOOT_COMPLETED Intent.

Here is my (relative) Android.Manifest File:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>    
<receiver android:name=".BootReceiver"
        android:enabled="true"
        android:exported="true"
        android:label="BootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"></action>

        </intent-filter>
    </receiver>

And Here is the actual Receiver.

public class BootReceiver extends BroadcastReceiver {
private static final String TAG="BootReceiver";

@Override public void onReceive(Context context,Intent intent){
    try{
        context.startService(new Intent(context,ConnectivityListener.class));
        Log.i(TAG,"Starting Service ConnectivityListener");
    }catch(Exception e){
        Log.e(TAG,e.toString());
    }
}
}

Thanks! Any help is greatly appreciated

Answer

fklappan picture fklappan · Apr 11, 2012

You can emulate all broadcast actions by connecting via adb to the device and open a device shell.

Here we go:

  • open console/terminal and navigating to /platform-tools
  • type adb shell or on linux/mac ./adb shell
  • in the shell type am broadcast -a android.intent.action.BOOT_COMPLETED or whatever action you want to fire

There are a bunch of nice commands coming with adb or the adb shell. Just try it

Regards Flo

edit: oh damn, i wanted this answer as an answer on the "had to turn phone on/off every time". sorry folks