Reputation: 10555
E.g. When I switch from App A to App B, I thought the App A would become a "cached background process". Does this mean the memory used by App A's is copied to "disk(SD Card)"? Is the memory occupied by A available to use by other Apps?
Further, how to recover App A when I switch back? What cause the recovering delay if there is any?
Upvotes: 1
Views: 430
Reputation: 132
App A will stay in memory so long as Android leaves it there. If you want to direct your apps functions through this transition you need to override OnPause() and OnResume(). eg.
@Override
protected void onPause(){
// YOUR CODE HERE
super.onPause();
}
@Override
protected void onResume(){
// YOUR CODE HERE
super.onResume();
}
Onpause is thrown when you press the home button, get a call etc. it gives you a chance to stop your threads (tell your app to stop working) and do anything you have to before the focus is lost. It is not a great time to save data because that can take too long and a user will expect the app to disappear immediately.
OnResume is thrown when you open your app again, this is where you start your thread again (tell your app to start working)
Upvotes: 1