java.lang.Illegalstateexception in Broadcastreceiver

Asked

Viewed 103 times

1

I’m getting the following error on the console of my android app, this error shows the warning that the App stopped even not using it:

Caused by: java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1520)
  at android.app.ContextImpl.startService (ContextImpl.java:1476)
  at android.content.ContextWrapper.startService (ContextWrapper.java:644)
  at android.content.ContextWrapper.startService (ContextWrapper.java:644)
  at com.emerson.barcellos.mgordenservico.Controllers.BootCompletedIntentReceiver.onReceive (BootCompletedIntentReceiver.java:14)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3273)

Bootcompletedintentreceiver that keeps Longpolingrservice.class active:

public class BootCompletedIntentReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
            Intent pushIntent = new Intent(context, LongPolingrService.class);
            context.startService(pushIntent); //Linha 14
        }
    }
}

Manifest:

...<receiver
        android:name="com.emerson.barcellos.mgordenservico.Controllers.BootCompletedIntentReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>...

Does anyone know the reason for the mistake? Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.