Last active
May 22, 2024 06:32
-
-
Save chandruark/3165a5ee3452f2b9ec7736cf1b4c5ea6 to your computer and use it in GitHub Desktop.
used to get Autostart option for Alarm Manager in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.ChainLaunchAppListActivity")); | |
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)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i have oneplus nord2 5g and not work with me