I have two activities in an android application, each has a button that goes to the other activity (by startActivity() method). In the second activity, I have an edit text (URL address bar) and a web view.
So, when I click on the button of activity1 to start activity2, I get activity2 with the web view. Then I type cnn.com (for example) in the address bar and my web view displays the cnn.com web site. After that, I click on the button to go from activity2 to activity1.
If I click again on the button of activity1, I start activity2. But activity2 has just been created, I mean, the edit text and the web view are empty.
What I want is: if I return from activity1 to activity2, I want activity2 to keep the last state: the edit text should keep cnn.com and the web view should keep displaying the CNN web site.
So what I need is not to quit activity2 before starting activity1, but something like just hiding it and starting activity2, so that if I return to it again, I get its last state. (Like when I click on the home button.) How can I achieve this?
Here is a suggestion to solve your problem.
when you go from Button that is in Activity two and now you are in Activity one make sure that when you move from activity two to one, it should not finish activity two.
Now when you want to go back to Activity two So you need to call your Activity like this in below.
so what this code does is it will make Activity to come over first without creating a new instance of activity and you can see that your last loaded website it there.