[Android Only] Added 'isDeviceIdleMode' function

pull/1/head
Max Bassett 8 years ago committed by GitHub
parent 32abd15d9a
commit a6a858f12b

@ -79,6 +79,18 @@ public class PowerManagement extends CordovaPlugin {
} catch (Exception e) {
result = new PluginResult(PluginResult.Status.ERROR, "Could not set releaseOnPause");
}
} else if( action.equals("isDeviceIdleMode")) {
// Only available since API 23
if (android.os.Build.VERSION.SDK_INT >= 23) {
try {
callbackContext.success((this.powerManager.isDeviceIdleMode() ? 1 : 0));
} catch (Exception e) {
result = new PluginResult(PluginResult.Status.ERROR, "Could not get device idle status.");
}
}
else {
result = new PluginResult(PluginResult.Status.ERROR, "Android version too old to use isDeviceIdleMode().");
}
}
}
catch( JSONException e ) {

Loading…
Cancel
Save