1
After many researches I came across the following situation: I’m on my own Main Activity and would like to open another Activity(passing parameters to Activity2[In case a meditate]), after this use the back button on Toolbar and return to Main.
Problems: I’m unable to maintain the class instance main, when the return is made by Actionbar is made a new creation of Mainactivity, thus losing the current state of the main.
Note1: Parameter passages are ok, only missing the main instance.
intent2 = new Intent(this, meditate.class);
public void passartextos(String tituloE, String textoE){
intent2.putExtra("titulo", tituloE);
intent2.putExtra("texto", textoE);
startActivity(intent2);
}
In Activity meditate was made the changes in XML according to a topic of the forum BR Stackoverflow Problems with getSupportActionBar() to Home (arrow) button and back arrow
In the class meditate has been introduced supportactionbar line
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
and in the Androidmanifest
<activity android:name=".meditate"
android:parentActivityName=".MainActivity"></activity>
When you’re a kid, it comes down to:
Mainactivity -> Meditate
Meditate -> New Mainactivity
What do you mean? When you return you are setting another onCreate?
– viana
What do you want to happen when you click the back button? Should you press something in the previous class? I don’t get it very well.
– viana
When I return is done another Oncreate and when I return I just want to give Finish na Activity Meditate.
– Sayoan Oliveira
On your device’s native back, when you click while on Meditate what happens?
– viana
Go back to Main the way I want, without running onCreate.
– Sayoan Oliveira