I am trying to check whether the user already has an autostart permission to avoid the permission dialog.
Asked
Active
Viewed 261 times
0
-
If you are asking about the Auto Start Option some Manufactures has .. You can't check this .. To Check Battery optimization status see [this thread](https://stackoverflow.com/questions/39256501/check-if-battery-optimization-is-enabled-or-not-for-an-app). – ADM May 30 '19 at 13:10
-
Check out this may be it will help https://stackoverflow.com/questions/39366231/how-to-check-miui-autostart-permission-programmatically – SaiAbhijit May 30 '19 at 13:29
1 Answers
-1
It is not possible to verify that the autostart option is enabled or disabled in your app. What you can do is, you can ask the user for enabling it manually when the user opens the app for the first time.
You can redirect the user to autostart permission's settings page for enabling your app using the following code:
Intent intent = new Intent();
String manufacturer = android.os.Build.MANUFACTURER;
if ("xiaomi".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
} else if ("oppo".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
} else if ("vivo".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
} else if ("Letv".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
} else if ("Honor".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
}
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
startActivity(intent);
}

SHAHEEN BSV
- 56
- 7