今天我在 map 中创建了一个应用程序,但是当节电模式打开时它崩溃了。
如何在节电模式打开时检查事件,对于每台设备,帮助我。谢谢
我试试这个,但在 API <21 中不起作用:
PowerManager powerManager = (PowerManager)
this.getSystemService(Context.POWER_SERVICE);
if ( powerManager.isPowerSaveMode()) {
// Animations are disabled in power save mode, so just show a toast instead.
Toast.makeText(customer_textReport.this, "Vui lòng tắt chế độ tiết kiệm pin", Toast.LENGTH_SHORT).show();
}
else {
Intent intentvitri = new Intent(customer_textReport.this, CustomerGetLocation.class);
startActivityForResult(intentvitri, 111);
}
最佳答案
检查谷歌开发者:PowerManager
在左上角,您可以更改 API 级别。
如您所见,isPowerSaveMode() 是在 API 21(Lollipop) 中添加的。
因此它不适用于旧设备。
关于android - 如何在 android API <21 中检查省电模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33277525/