I have a few activities, on the Acivity 1 I set a variable active which is true.
Activity 1 => Activity 2 => come back to Activity 1
active=true => active=false => active=false
I got:
Activity 1:
public boolean active = false;
onCreate() {active = true;}
Intent i = new Intent(Activity1.this, Activity2.class);
startActivity(i);
This activity must work in the background.
Activity 2:
public boolean active = false;
Intent intent = new Intent(Activity2.this, Activity1.class);
intent.putExtra("active", active);
then I call method onBackPressed();
But when I come back Activity 1 appears and I obtain active = true:
onResume()
and onRestart()
here I have:
Intent intent = getIntent();
active = intent.getBooleanExtra("active", active);
When I tried to use startActivityforResult() method from Activity 1 it doesn't move to the Activity 2 and it's still true.
May be its because I have a main layout in both activities and contents changes. How to resolve this?