2

I am trying to catch the BOOT_COMPLETED intent. In my receiver, I just print something to the Log. In Logcat I get this error, and the log statement that I put never prints out. I have set the permission in the manifest for

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

And have also declared the required intent filter in my receiver. What am I doing wrong?

Suchi
  • 9,989
  • 23
  • 68
  • 112

2 Answers2

3

What am I doing wrong?

That's impossible to answer given the limited information you have supplied. Perhaps your action string is wrong in your <intent-filter>.

Here is a sample project that does just what you describe (boot-time receiver writing a message to LogCat).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

I had the problem too, found this answer and solved it by diffing with CommonsWare's sample code:

You will get this error, when you call setResultData(...) in the onReceive()-Method of the BroadcastReceiver and reacting to a non-ordered Broadcast. It looks like the boot broadcast is non-ordered. see also: Developer docs

@Override
public void onReceive(Context context, Intent intent)
{
    try
    {
            Intent serviceIntent = new Intent(context, MyService.class);                
            context.startService(serviceIntent);
            // setResultData(null);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
Minsky
  • 2,106
  • 28
  • 31