Posts

Showing posts with the label Android Doze

Android Notifications Triggered By Alarm Manager Not Firing When App Is In Doze Mode

Answer : 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); I have faced the similar problems. I tried with work manager but the result was same. When phone is locked and is in doze mode the event are not triggered. But for triggering event at exact time you need to use alarm manager only. It should work even in doze mode. Method to register alarm manger (use set exact time instead of repeating) public static void registerAlarm(Context context){ final int FIVE_MINUTES_IN_MILLI = 300000; final int THIRTY_SECOND_IN_MILLI = 30000; long launchTime = System.currentTimeMill...