Skip to content Skip to sidebar Skip to footer

Alarmmanager Not Set Or Not Firing On Marshmallow After Certain Time

I have been successfully using the following construct to start an AlarmManager in some of my apps upto Android 5: Intent serviceIntent = new Intent(context, MyService.class);

Solution 1:

Of course, try with:

setAlarmClock(AlarmManager.AlarmClockInfo info, PendingIntent operation)

Doze mode dont start if you set the alarm this way.I tested this on console.

Dont forget that AlarmClock Info have a different PendingIntentthat setAlarmclock.

UPDATE

If you want to make a simple alarm(not alarmclock).

this have to work

setExactAndAllowWhileIdle(int type, long triggerAtMillis, PendingIntent operation)

But i now that it doesn't. So i started looking and google and i found this. A possible way to add an app to doze whitelist. Maybe setExactAndAllowWhileIdle works.

https://developer.android.com/training/monitoring-device-state/doze-standby.html?hl=es

Users can manually configure the whitelist in Settings > Battery > Battery Optimization. Alternatively, the system provides ways for apps to ask users to whitelist them.

An app can fire the ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS intent to take the user directly to the Battery Optimization, where they can add the app. An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can trigger a system dialog to let the user add the app to the whitelist directly, without going to settings. The app fires a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the dialog. The user can manually remove apps from the whitelist as needed. Before asking the user to add your app to the whitelist, make sure the app matches the acceptable use cases for whitelisting.

Post a Comment for "Alarmmanager Not Set Or Not Firing On Marshmallow After Certain Time"