How to resume state of application
I have one activity which starts multiple threads and one doInBackground method. when I launch it is working fine.
But everytime I press the back button of the emulator and then again double click of t开发者_如何学Gohis app it creates a new instance of the application rather than resume it where it is now.
I had searched out and read about onRetainNonConfigurationInstance() but how to return instance off all the threads and doInBackground method
Hope anyone will understand my problem and what actually I what to do.
I think you have to restore the state when the app runs again. For this you have to get the Back key event
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
moveTaskToBack(true);
}
return true;
}
Hope this will help you...
By default, pressing back will automatically finish
your activity (assuming that it is the topmost activity). It is not clear, from your description, where you want the app to resume from.
As per my understanding
Your thread might not be terminating. Can you check in DDMS does your thread really running and it is not stoping. Does your thread acquiring any lock and not releasing. Can you explain your problem more clearly if possible can you show your code.
精彩评论