1

I want to check whether device is in a maintenance window of doze mode.

so I used :

//on receive alarm broadcast
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean isDeviceIdleMode = pm.isDeviceIdleMode();
//do work

but realized that it returned false always.

After referring to documentation, I found that,

it will return false if the device is in a long-term idle mode but currently running a maintenance window where restrictions have been lifted.

Is there a method like isDeviceInMaintenanceWindow or how can I programmatically detect it?

Nilanka Manoj
  • 3,527
  • 4
  • 17
  • 48
  • 1
    [This answer](https://stackoverflow.com/questions/45649269/how-to-differentiate-between-the-device-entering-a-doze-maintenance-window-and-c) has at least a partial workaround for detecting "maintenance window" vs "leaving doze completely." Even the answer notes its a hack though. [This answer](https://stackoverflow.com/questions/61597568/is-there-a-way-to-identify-when-device-comes-out-of-doze-mode-or-is-in-maintenan) has other alternatives, although the commenters make good points about Google not providing too much "in maintenance window" info because apps will all try to race / compete. – G. Putnam Jan 01 '23 at 19:42

0 Answers0