Skip to content

Instantly share code, notes, and snippets.

@chandruark
Last active May 22, 2024 06:32
Show Gist options
  • Save chandruark/3165a5ee3452f2b9ec7736cf1b4c5ea6 to your computer and use it in GitHub Desktop.
Save chandruark/3165a5ee3452f2b9ec7736cf1b4c5ea6 to your computer and use it in GitHub Desktop.
used to get Autostart option for Alarm Manager in Android
private void addAutoStartupswitch() {
try {
Intent intent = new Intent();
String manufacturer = android.os.Build.MANUFACTURER .toLowerCase();
String model= Build.MODEL;
Log.d("DeviceModel",model.toString());
switch (manufacturer){
case "xiaomi":
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
break;
case "oppo":
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
break;
case "vivo":
intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
break;
case "Letv":
intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
break;
case "Honor":
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
break;
case "oneplus":
intent.setComponent(new ComponentName("com.oneplus.security", "com.oneplus.security.chainlaunch.view.ChainLaunchAppListAct‌​ivity"));
break;
}
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
startActivity(intent);
}
} catch (Exception e) {
Log.e("exc" , String.valueOf(e));
}
}
@mhd-aldawood
Copy link

i have oneplus nord2 5g and not work with me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment