What exactly happens when you remove a task from retentates?

I noticed amazing behavior when uninstalling an application from the application switcher by scrolling. The application has a service. When the application is "killed", all threads launched from the service continue to work, other threads terminate.

What is really surprising is that the system can determine which threads were started from the service, even if I try to obfuscate the origin of the stream as follows:

  • In the service onCreate () method, send runnable to the main thread handler.
  • Runnable launches a new thread that survives removal from recents.

If I send the same as to the same handler, but from activity, the stream does not survive. How can a system know? Does it somehow keep track of which thread was runnable sent from?

Edit: on request the onCreate () method:

@Override public void onCreate() { super.onCreate(); new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { new Thread(){ @Override public void run() { while (true) { System.out.println("hello from thread"); try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } } } }.start(); } }, 1000); } 
+5
source share
3 answers

Finally it turned out what was happening. The system does not selectively kill non-service-related threads, it kills the entire application and then starts the service again, so it seems that the service threads were untouched.

+2
source

I just want to shed some light on this.

Android components do not pay attention to threads that they did not create. Thus, while the IntentService will handle the thread that it created to use onHandleIntent (), the regular service does not pay attention to any threads that you yourself are developing.

Once the service is destroyed, all streaming threads will continue to work until Android completes the process.

If your threads stop unexpectedly, this has nothing to do with the Service — the Service knows nothing about the threads you are deploying yourself.

+1
source

From the links

it terminates the application in the same way as it happens again and again. Sometimes this kills its background processes, but sometimes it’s not:

Deleting a record in recent tasks will destroy any background processes that exist for the process. This does not cause the services to stop, but there is an API to find out if the task has been deleted, to decide if they want it to mean that they should stop. This means that deleting, say, a recent task of an email application will not stop the email check.

If you really want to completely stop the application, you can click on recent tasks for a long time to go to the information about the application and hit it. Force stop is the complete destruction of all applications, all processes are killed, all services are stopped, all notifications are deleted, all alarms are deleted, etc. The application is not allowed to run again until explicitly requested.

So, basically, this is a solution for the application, and depends on how the application was encoded. It’s worth looking at the screen under “Settings”> “Applications”> “Launch” to see how each application works.

Please check the refrence link below for more information.

Links to links: -

http://lifehacker.com/what-happens-when-you-remove-an-app-from-androids-mult-1179868228

http://www.howtogeek.com/169549/what-exactly-happens-when-you-swipe-an-android-app-from-the-recent-apps-list/

https://plus.google.com/+DianneHackborn/posts/GfwRYCC42uX

0
source

All Articles