0

activity manager clear all recent and kill process in background?

-Can system destroy only one or some of my activities to recover memory?

-Will system kill the whole process of my application? Will all activities be nicely destroyed? i'll use code but don't work

    mgr.killBackgroundProcesses(p.processName);
Quang Long
  • 31
  • 3

2 Answers2

0

When your activity receives a call to the onStop() method, it's no longer visible and should release almost all resources that aren't needed while the user is not using it. Once your activity is stopped, the system might destroy the instance if it needs to recover system memory. - http://developer.android.com/training/basics/activity-lifecycle/stopping.html

So yes the system can destroy your activity when its not visible.

Depending on how its destroyed, it might save an instance by calling the onSaveInstanceState(), and when it resumes it will call the onRestoreInstanceState(). This article has more information on the questions.

Atish
  • 1,239
  • 1
  • 12
  • 10
0

First of all I have to say that Google does not recommended to kill any process.

This migh be helpful for you: Is quitting an application frowned upon? and

Android destroying activities, killing processes

I hope these links will answer all your questions.

If you want to finish your activity use finish();

Here are the examples how you can destroy your app: https://stackoverflow.com/a/26586015/3864698

Community
  • 1
  • 1
QArea
  • 4,955
  • 1
  • 12
  • 22