Does setAndAllowWhileIdle()
or setExactAndAllowWhileIdle()
actually wake up the device from Doze mode? And does it remove the restriction on Network Access?
Asked
Active
Viewed 2,145 times
2

shashank chandak
- 544
- 5
- 13

Tsunaze
- 3,204
- 7
- 44
- 81
-
2No, For waking up device from doze mode using alarmmanager, you have to use setAlarmClock() method. Check complete answer [here](https://stackoverflow.com/a/49504928/7804719) – Jaydip Kalkani Sep 04 '18 at 09:52
-
But If I use the WorkManager, it will still launch? But with no internet connection, since we will still be in Doze mode? – Tsunaze Sep 04 '18 at 10:00
-
I didn't get what you want to do...but let me clear how `setAlarmClock()` method works. If you use `setAndAllowWhileIdle()` or `setExactAndAllowWhileIdle()` and if your device is in doze mode then it will not fire alarm broadcast. Instead it will wait until user turns screen on and device get back to normal mode. Now, if you use `setAlarmClock()` method and if your device is in doze mode...then also it will fire broadcast. Actually `setAlarmClock()` method wakes up your device from doze mode before some time of your alarm. – Jaydip Kalkani Sep 04 '18 at 10:06
-
I want to enable an alarm even in doze mode and do some work that need an internet connection (downloading). In Android developer reference, it states : "setExactAndAllowWhileIdle : Like setExact(int, long, PendingIntent), but this alarm will be allowed to execute even when the system is in low-power idle modes. If you don't need exact scheduling of the alarm but still need to execute while idle, consider using setAndAllowWhileIdle(int, long, PendingIntent)." – Tsunaze Sep 04 '18 at 12:05
-
1Okay, then it's clear. You can use `setAlarmClock()` method as stated [here](https://stackoverflow.com/a/49504928/7804719). It will enable an alarm even in doze mode and inside your broadcast receiver for alarmmanager you can write download file logic. That's it. – Jaydip Kalkani Sep 04 '18 at 12:29