I have two activities FirstActivity
and SecondActivity
. When I am in FirstActivty
I call the SecondActivity
like that:
var secondActivity = new Intent(this, typeof(SecondActivity)); secondActivity.PutExtra("someExtra", someExtra); StartActivity(secondActivity); Finish();
In SecondActivity
I call the FirstActivity
in OnBackPressed
method:
public override void OnBackPressed() { StartActivity(typeof(FirstActivty)); Finish(); }
I looked at answers regarding that question for Android(Java)
. The answers were that in order to avoid OnCreate
method to be executed in FirstActivity
when the activity has been already created, I don't have to destroy FirstActivity
after I open SecondActivity
, I have to remove Finish()
after StartActivity(secondActivity);
line. I removed it but OnCreate
method still gets executed when I go back from SecondActivity
. Does this solution work only in Android(Java)
,and if yes, what is the solution for Xamarin.Android
?