Android Notifications triggered by Alarm Manager not Firing when App is in Doze Mode

前端 未结 5 1042
無奈伤痛
無奈伤痛 2021-02-01 09:14

I have the following requirements. A user needs to be able to schedule a recurring reminder in my app that will trigger a push notification at an exact time ev

5条回答
  •  臣服心动
    2021-02-01 09:54

    Adding an intent Flag FLAG_RECEIVER_FOREGROUND

    https://developer.android.com/reference/android/content/Intent#FLAG_RECEIVER_FOREGROUND prior to calling the broadcast receiver should do the trick

    Intent intent = new Intent(context, ScheduleAllReceiver.class);
    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent scheduleAllPendingIntent = PendingIntent.getBroadcast(context, SCHEDULER_DAILY_ALL, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    

提交回复
热议问题