无法在广播接收器上启动接收器

时间:2018-02-23 14:32:01

标签: java android broadcastreceiver

我正在开发Android应用程序,我已经实现了Alarm Manager,每小时后运行一些数据库操作。一切都运行良好,但在背景上一段时间应用程序崩溃。

AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(HomeActivity.this, DailyMethodService.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(HomeActivity.this, 0, i, 0);

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, SystemClock.elapsedRealtime(), 3600000, pendingIntent);

这是我的广播接收器

@Override
public void onReceive(Context context, Intent intent) {
    this.context = context;
    getData(context);
    getTagedRFP();
}

logcat的

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.firebase.INSTANCE_ID_EVENT pkg=com.MWBE.Connects.NY cmp=com.MWBE.Connects.NY/com.google.firebase.iid.FirebaseInstanceIdService (has extras) }: app is in background uid UidRecord{17ca21a u0a90 RCVR bg:+5m26s800ms idle procs:1 seq(0,0,0)}
   at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
   at android.app.ActivityThread.-wrap17(Unknown Source)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
   at android.os.Handler.dispatchMessage(Handler.java:105)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6541)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

0 个答案:

没有答案