How to not destroy current activity when back is presse?

It is android default behavior when you click on return(escape) or back button,it finishes the current activity and loads the previous activity. If you do not want the default behavior you can override the onKeyDown method it will help you. See the example code in the following doc URL developer.android.com/reference/android/... Are you doing any network or similar operations in Act2 which you do not want do next time?

Yes sir, I am doing some networking in act2 that I want to save unless the user wants to refresh. – unknown Jul 1 at 18:31 1 then put a flag in Act2 which indicates that the data is downloaded,so you can check the flag every time and make your operation,you can save this flag in database or use shared preferences to save the flag. – sunriser Jul 1 at 18:53.

You could set the launch mode to "singleTop" as described in the docs and catch the back button presses to start a new Intent, that will reveal the old activity because they are singleTop.

You could override the onPause method in Act2 and save your info in a SharedPreferences object, which would be retrieved in the onCreate() on returning.

I have a button in Act1 that starts a new intent to Act2 when it is pressed. However whenever I hit the back button while in Act2, than click the button again is restarts a new Intent. I do not want it to do that... I want it to resume Act2.

How can I go about doing it?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions