My application has a non-sticky service running, whenever I close the app from the task manager by swiping it, it also kills my service instantly. I am facing this issue only in Oppo phones.
-
You need to enable auto enable manager for oppo phones – Shivam Oberoi Jan 08 '18 at 11:38
-
@ShivamOberoi can you plz explain a lil.. how & why... – Adeel Turk Jan 08 '18 at 11:59
-
If you use START_NOT_STICKY then service will be removed when user kills the app.But if you use START_STICKY, even if user kills the app user service will get restarted. – Sonu Sanjeev Jan 08 '18 at 12:26
-
@SonuSanjeev i know thats why i have mentioned both sticky and non sticky .. plus it working in other phones except my oppo f3 .. – Adeel Turk Jan 08 '18 at 12:45
2 Answers
On the Oppo F1 you need to add COL Reminder to the "Startup Manager" to allow running in the background.
Go to "Security Center". Click "Privacy Permissions" Then "Startup manager" And allow "COL Reminder" to run in the background.
If it is still not working please check this steps:
Go to settings > Battery and Storage > Battery Manager > Tap on "Power consumption details" > Optimize for excessive power consumption. Now uncheck all the apps you are facing issues with.

- 1,713
- 15
- 28
-
Right... please check on your phone and let us know its working or not – Nirav Joshi Jan 08 '18 at 12:15
-
nope .. its not!! i have checked for startup boot and from battery management i have selected not to optimize for my app .. but all in vain so far – Adeel Turk Jan 08 '18 at 12:45
Many smartphones like Xiamoi, Oppo, Vivo kills background services even if it is running with flag START_STICKY
to improve resource/battery optimization.
You can't set autostart to be enabled by-default programmatically.
Many solutions/suggestions have already been answered in many threads.
This one is taken from this thread, it takes user to respective auto-start/startup-manager/security-center, you can ask user to enable auto-start for your app by showing toast/alert, rest all depends on user:
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);
}
P.S. auto-start is enabled by-default for some apps like Facebook, Instagram and other Facebook family apps, they may have an agreement with device manufacturers.

- 833
- 1
- 7
- 11
-
i have already visited that thread and the answer above yours (from @Nirav Joshi) is almost the same but problem is that after enabling those options i still can't get the expected results – Adeel Turk Jan 09 '18 at 06:25
-
-
Sometimes it revokes after a time-period of 5-10 mins, depends on resources available and resources required by your service, please check in running services after 5-10 minutes. – global_warming Jan 09 '18 at 06:35
-
ahan.. ok i will get back to this thread soon .. right now i m in a rush.. – Adeel Turk Jan 09 '18 at 06:43