我只是想在我的应用中禁用电池优化。我使用了下面的代码fragmentIntentintent=newIntent();StringpackageName=context.getPackageName();PowerManagerpm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);if(pm.isIgnoringBatteryOptimizations(packageName))intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTIN
如文档中所述:"AnappholdingtheREQUEST_IGNORE_BATTERY_OPTIMIZATIONSpermissioncantriggerasystemdialogtolettheuseraddtheapptothewhitelistdirectly,withoutgoingtosettings.TheappfiresaACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONSIntenttotriggerthedialog."有人能告诉我触发这个Intent的正确方法吗? 最佳答案
如文档中所述:"AnappholdingtheREQUEST_IGNORE_BATTERY_OPTIMIZATIONSpermissioncantriggerasystemdialogtolettheuseraddtheapptothewhitelistdirectly,withoutgoingtosettings.TheappfiresaACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONSIntenttotriggerthedialog."有人能告诉我触发这个Intent的正确方法吗? 最佳答案
我正在尝试在模拟器(API25)上启动将应用程序列入白名单的Activity,但我不断收到一条错误消息:Causedby:android.content.ActivityNotFoundException:NoActivityfoundtohandleIntent{act=android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}这是我的代码:@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);Intentint