I would like to know whether the background service for any application can be provided by xiaomi? I have service in my app which need to be running in background all the time , in all devices its working fine except Xiaomi, how it can be done programmatically?
Asked
Active
Viewed 5,735 times
1 Answers
11
Works for xiaomi, oppo, vivo and oneplus phones as well.
try {
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("oneplus".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.oneplus.security", "com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity")); }
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
context.startActivity(intent);
}
} catch (Exception e) {
Crashlytics.logException(e);
}

Vipul Asri
- 8,903
- 3
- 46
- 71

rajkumar
- 489
- 5
- 6
-
1What is for one plus? – Janardhan Y Aug 02 '17 at 12:03
-
@JanaBabu use this if ("oneplus".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.oneplus.security", "com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity")); } – RaRa Oct 04 '17 at 07:34
-
How do we know if user has granted the Autostart or the not? – VahidShir Apr 16 '19 at 12:43
-
There is no way to know – Debasish Ghosh Dec 17 '19 at 05:34
-
1@RaRa I'm getting error in opening settings on oneplus. any update on it ? has oneplus removed it. – akshay bhange Jun 05 '20 at 11:11