9

My app has background service which keep on running even if app is killed from the task manager but when I have tested my app on MI(xiaomi) phone it kills my app service when I close the app from task manager and my service keep on running and work perfectly on all devices except MI even if I kill my app from task manager.

So how to keep my service running in background even when the app is killed from the task manager?

6
  • It depends on android os for making this decision to free resources. You can have a look on IntentService to have more optimized way of using background services. Commented Jul 11, 2015 at 8:32
  • @JibranKhan but my service is running on ll device even if i kill app..because i am sending an broadcast when on destroy get fired .. but only in xiaomi it is not working... Commented Jul 11, 2015 at 9:02
  • Well onDestroy() itself is not guaranteed to be fired every time app closes or exits. Also do check if there is anything to do with android versions in your 2 other phones as compared to Xiaomi Commented Jul 11, 2015 at 9:09
  • @JibranKhan but on the same device whats app service keep on running all the time it consumer much more memory than my service why so..? Commented Jul 11, 2015 at 9:45
  • @Edward if its not late, you can check this link - stackoverflow.com/a/41360159/2798289 Commented Dec 30, 2016 at 6:07

2 Answers 2

6

MIUI has a built-in Security app. In the Security app there is a 'Autostart' section, where the user can configure which app can and which app can't run on startup. Your application is disabled default. You need to enable your app and also enable permission manager from permission section.

Sign up to request clarification or add additional context in comments.

5 Comments

But user doesn't gonna do this him/her self so is there any other way to do it programmatically w/o user interaction
I have did it in MIUI 8 and removed app from task manager and app background service has been stopped....
@himCream how you did this in programmatic way. Can you please share the code. I've been waiting for long time to fix this issue. Thanks in advance.
@moorthy sorry, I din't get, Which code do you want from me?
To make our app into whitelist by programmatically (i,e how to do we enable auto-start for our app)
0

You should select release build variant from android studio because MI has disabled debugging mode.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.