I am developing an app with three activities called Activity Ex1, Ex2 and Ex3. The Ex2 and Ex3 activities has No History = true flag manifest file.
Ex1 is the main activity
my app flow is Ex1<->Ex2-->Ex3
I will set some values in the Ex1 Activities when the app is loaded such as no of counting and setting values for some boolean values.
In the first launch it works correctly. After that I go to Ex1 to Ex2 and come back to Ex1 by using intent (because I have to pass values from Ex2 to Ex1), so that the activity Ex1 values are reset again it causes wrong calculation in my app.
My requirement is whenever I open the app in that time only no of counting to be increased and done other setting values. The counting variables and setting variables should not be changed/modified whenever I am moving between Ex1 to Ex2, Ex2 to Ex1. Those should be effected only when I open the app. How do I do this?
Here’s approach without using shared preferences. I havent tested this, but it should work…
If i understand you correctly you switch between activities
Ex1andEx2like this:So when switching to another activity, you can put additional boolean flag saying that your activity was switched from another activity. So when switching to
Ex1, put put this in yourEx2(and possibly all other activities that switch toEx1)Then, just put following condition in your
Ex1activity, in place where you are setting data (typicallyonCreatemethod)