Android 7.1.1设备中销毁的FirebaseMessagingService扩展服务类

时间:2019-07-10 05:33:36

标签: android notifications firebase-cloud-messaging

我已经为actionbuttons click事件设置了广播接收器,并在FirebaseMessagingService的oncreate()方法中注册了该接收器,并在ondestroy()方法中取消了该接收器的注册,因此这些Action Buttons Click事件不起作用。此问题仅在比oreo更低的android版本中发生

   public void onCreate() {
       super.onCreate();
//        create the notification action button listener
       notificationButtonClickReceiver = new NotificationButtonClickReceiver();
//        add actions for the receiver
       IntentFilter intentFilter = new IntentFilter();
       intentFilter.addAction(action1);
       intentFilter.addAction(action2);
       registerReceiver(notificationButtonClickReceiver, intentFilter);
   }

   @Override
   public void onDestroy() {
       super.onDestroy();        unregisterReceiver(notificationButtonClickReceiver);
   }

0 个答案:

没有答案