2

When I am using service in my Android application onTaskRemoved() Method doesn't call in some devices like redmi mi(in Redmi device,I clear the app by holding the home button and clear the recent apps, onTaskRemoved() method doesn't called but it will works some other devices like Motorola,One-plus and so on).

How to solve this Problem?

François Legrand
  • 1,151
  • 1
  • 14
  • 25
  • 1
    see this https://stackoverflow.com/questions/40660216/ontaskremoved-not-getting-called-in-huawei-and-xiomi-devices – jitendra purohit Jan 24 '18 at 12:00
  • https://stackoverflow.com/questions/40660216/ontaskremoved-not-getting-called-in-huawei-and-xiomi-devices - use this link i modified my source code still onTaskRemoved Method doesn't called,Only onDestroy method called which is present in my service class. – Revathi Manoharan Jan 24 '18 at 12:45
  • Is your app added to the list of apps what are allowed to run in the background? (protected apps) – David Wasser Jan 26 '18 at 10:29
  • can u please clarify your question? i am not using proguard rule in my application.(what are all the rules comes under protected )-https://stackoverflow.com/users/769265/david-wasser – Revathi Manoharan Jan 30 '18 at 06:25
  • i use START_STICKY in my application service class @David Wasser – Revathi Manoharan Feb 19 '18 at 12:20
  • some issue happens in 5.1.1 lenovo devices,i am trying to clear my application from recent apps,onTaskRemoved() method doesnot called -how to solve this issue@David Wasser @jitendra purohit – Revathi Manoharan Feb 19 '18 at 12:25
  • On certain devices, Android will only allow certain apps to run in the background. These apps need to be manually added to a list of "protected apps" (different manufacturers have different names for this). Lenovo is one vendor that has this. Huawei, Xiaomi and others also use this concept. You need to find the setting that controls this and add your app to this list. – David Wasser Feb 19 '18 at 12:36
  • If you don't have your app in the list of "protected apps", then `onTaskRemoved()` will not be called and Android will not restart your `Service` even though you return `START_STICKY` from `onStartCommand()`. – David Wasser Feb 19 '18 at 12:37
  • how to identify protected apps? how to add my app to protected apps list ? can you please tell me? @DavidWasser – Revathi Manoharan Feb 20 '18 at 13:01
  • I don't have this phone so I do not know. In any case I can tell you that you cannot programatically add your app to the list. You need to tell the user that he has to do it manually. Look in some Lenovo forums for help or just click through the Android settings. Good luck and let us know what you find! – David Wasser Feb 20 '18 at 15:26
  • Are you using protected apps in your any project? Except lenovo@David Wasser – Revathi Manoharan Feb 20 '18 at 15:31

0 Answers0