[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();
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
startActivity(intent);
return;
} catch (Exception e) {
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.oppoguardelf.Permission.BackgroundAllowAppListActivity"));
startActivity(intent);
return;
} catch (Exception e2) {}
}
} else if (manufacturer.contains("xiaomi")) {
try {
Intent intent = new Intent("miui.intent.action.APP_BATTERY_SAVER_SETTINGS");
intent.setComponent(new ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity"));
intent.putExtra("package_name", getPackageName());
intent.putExtra("package_label", getString(R.string.app_name));
startActivity(intent);
return;
} catch (Exception e) {}
}
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); if (manufacturer.contains("oppo") || manufacturer.contains("realme")) {
intent.setData(Uri.parse("package:" + getPackageName())); try {
startActivity(intent); Intent intent = new Intent();
} intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
startActivity(intent);
success = true;
} catch (Exception e) {
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.oppoguardelf.Permission.BackgroundAllowAppListActivity"));
startActivity(intent);
success = true;
} catch (Exception e2) {}
}
}
else if (manufacturer.contains("xiaomi")) {
try {
Intent intent = new Intent("miui.intent.action.APP_BATTERY_SAVER_SETTINGS");
intent.setComponent(new ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity"));
intent.putExtra("package_name", getPackageName());
intent.putExtra("package_label", getString(R.string.app_name));
startActivity(intent);
success = true;
} catch (Exception e) {}
}
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);