I'm using Xamarin Studio for my app. I'm having an issue similar to this one here. I'm calling StartActivityForResult with an intent that launches the camera. The camera takes the picture and returns to the application just fine, and the main activity's OnActivityResult is called. My issue is that, despite a call to base.OnActivityResult, my fragment's OnActivityResult is never hit.
I've looked through the solutions here on SO, which are generally:
1. Call base.StartActivityForResult instead of StartActivityForResult inside the fragment
2. Call base.OnActivityResult in the main activity's OnActivityResult to forward on unhandled request codes
3. Ensure launchMode in the manifest is not set to single
Code:
Fragment -
void AddImage(object sender, EventArgs e){
//Preparing intent here...
StartActivityForResult (intent, 0);
}
//no override keyword because I'm given a compiler error stating
//that there is no OnActivityResult to override
protected void OnActivityResult(int requestCode, Result resultCode, Intent data){
//I call resultCode.GetHashCode here because I'm using SupportFragment
base.OnActivityResult (requestCode, resultCode.GetHashCode(), data);
if (resultCode == Result.Canceled)
return;
//process image...
}
Main Activity -
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult (requestCode, resultCode, data);
//processing data from other intents at the main activity level
}