android.content.ActivityNotFoundException" android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" [英] android.content.ActivityNotFoundException "android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"
本文介绍了android.content.ActivityNotFoundException" android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试引导用户进行电池优化活动,它似乎对大多数用户都有效,除了我得到的装有Android 6的某些三星手机:
I'm trying to guide my users to the battery optimizations activity and it seems to be working for most except for some Samsung phones with Android 6 where I get:
Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS }
这是我用来启动它的东西:
This is what I am using to launch it:
Intent intent = new Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS");
startActivity(intent);
知道我应该在那些手机上启动什么吗?
Any idea what I should be launching on those phones?
谢谢.
推荐答案
使用以下代码检查您的应用是否已经忽略了电池优化,如果是,则显示弹出窗口以启用该功能. >
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(getPackageName())) {
Intent batterySaverIntent=new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:"+getPackageName()));
startActivity(batterySaverIntent);
}
}
这篇关于android.content.ActivityNotFoundException" android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文