Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent service stop when onTaskRemoved is calles?
    text
    copied!<p>I have a problem with music <code>Service</code> being stopped after "Swipe to exit" being performed on recent apps list in ICS. Service was started with <code>START_REDELIVER_INTENT</code> and it is automatically restarted after few seconds, but I want to prevent the stop at all.</p> <p>"Swipe to exit" behaviour is generally unknown and I base my whole knowledge on this <a href="https://android.stackexchange.com/questions/19987/what-actually-happens-when-you-swipe-an-app-out-of-the-recent-apps-list">thread</a>. It contains comments from one of Google employees:</p> <blockquote> <p>[W]hat specifically happens when you swipe away a recent task is it: (1) kills any background or empty processes of the application (see <a href="http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Lifecycle" rel="nofollow noreferrer">http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Lifecycle</a> for what this means), and (2) uses the new <a href="http://developer.android.com/reference/android/app/Service.html#onTaskRemoved(android.content.Intent)" rel="nofollow noreferrer">http://developer.android.com/reference/android/app/Service.html#onTaskRemoved(android.content.Intent)</a> API to tell any services of the application about the task being removed so it can do whatever it thinks is appropriate.</p> </blockquote> <p>and</p> <blockquote> <p>Actually, removing an entry in recent tasks will kill any background processes that exist for the process. It won't directly causes services to stop, however there is an API for them to find out the task was removed to decide if they want this to mean they should stop. This is so that removing say the recent task of an e-mail app won't cause it to stop checking for e-mail. If you really want to completely stop an app, you can long press on recent tasks to go to app info, and hit force stop there. For stop is a complete kill of the app -- all processes are killed, all services stopped, all notifications removed, all alarms removed, etc. The app is not allowed to launch again until explicitly requested.</p> </blockquote> <p>According to second comment, my <code>Service</code> should be able to decide for itself what it wants to do - instead it is stopped without any action from me and gets restarted later.</p> <p>Any ideas what to do with it? Using <code>START_STICKY</code> works exactly the same...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload