Tuesday, 27 December 2022

check whether android device in maintenance window

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?



from check whether android device in maintenance window

No comments:

Post a Comment