List of usage examples for android.provider Settings ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
To view the source code for android.provider Settings ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.
Click Source Link
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
@SuppressLint("NewApi") private void checkBatteryOptimization() { if (Build.VERSION.SDK_INT >= 23) { Intent intent = new Intent(); String packageName = mContext.getPackageName(); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else {/*from ww w .ja v a 2s . c o m*/ intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); } startActivity(intent); } }
From source file:be.blinkt.openvpn.activities.MainActivity.java
@TargetApi(Build.VERSION_CODES.M) private void requestDozeDisable() { Intent intent = new Intent(); String packageName = getPackageName(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else {//from w w w. ja v a 2 s . c o m intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); } startActivity(intent); }