[MA] mejora de opciones para bateria

This commit is contained in:
Luis Guzmán 2026-03-12 11:06:21 -06:00
parent 93398afc8e
commit a3cc0808e6
1 changed files with 38 additions and 30 deletions

View File

@ -404,36 +404,44 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
} }
private void openBatterySettings(String manufacturer) { private void openBatterySettings(String manufacturer) {
if (manufacturer.contains("oppo") || manufacturer.contains("realme")) { boolean success = false;
try {
Intent intent = new Intent(); if (manufacturer.contains("oppo") || manufacturer.contains("realme")) {
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")); try {
startActivity(intent); Intent intent = new Intent();
return; intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
} catch (Exception e) { startActivity(intent);
try { success = true;
Intent intent = new Intent(); } catch (Exception e) {
intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.oppoguardelf.Permission.BackgroundAllowAppListActivity")); try {
startActivity(intent); Intent intent = new Intent();
return; intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.oppoguardelf.Permission.BackgroundAllowAppListActivity"));
} catch (Exception e2) {} startActivity(intent);
} success = true;
} else if (manufacturer.contains("xiaomi")) { } catch (Exception e2) {}
try { }
Intent intent = new Intent("miui.intent.action.APP_BATTERY_SAVER_SETTINGS"); }
intent.setComponent(new ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity")); else if (manufacturer.contains("xiaomi")) {
intent.putExtra("package_name", getPackageName()); try {
intent.putExtra("package_label", getString(R.string.app_name)); Intent intent = new Intent("miui.intent.action.APP_BATTERY_SAVER_SETTINGS");
startActivity(intent); intent.setComponent(new ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity"));
return; intent.putExtra("package_name", getPackageName());
} catch (Exception e) {} intent.putExtra("package_label", getString(R.string.app_name));
} startActivity(intent);
success = true;
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); } catch (Exception e) {}
intent.setData(Uri.parse("package:" + getPackageName())); }
startActivity(intent);
} if (!success) {
try {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);
} catch (Exception ex) {
}
}
}
private void toggleTheme() { private void toggleTheme() {
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);