arsena
arsena

Reputation: 1975

Handle Activity Finishing Event In Xamarin.Android

Is there anything similar to FormClosingEvent in Xamarin.android?

I have two activities - A and B. B is saving some data and is called from A on button click. I have list of data in A and want to automatically update it after B activity is finished.

Any suggestions how to do it?

Upvotes: 1

Views: 3291

Answers (1)

AlexC
AlexC

Reputation: 10756

It sounds like you want to use StartActivityForResult with Activity A starting activity B in the following manner

var myIntent = new Intent (this, typeof(ActivityB));
StartActivityForResult (myIntent, 0);

ActivityA should also then override OnActivityResult waiting to respond to activity B's response code and update as necessary.

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
  base.OnActivityResult(requestCode, resultCode, data);
  if (resultCode == Result.Ok) {
     // Do whatever needs to be done in A 
  }
}

This is all documented quite well in Xamarin's Android documentation

Upvotes: 1

Related Questions