My Xamarin app allows the user to take a new, or select an existing image.
It works perfectly fine on almost all devices, but I'm getting error reports from Samsung Galaxy S7 users and it appears that the intent data is null after those users select an existing image from their gallery.
Here's how I setup the intent:
var intent = new Intent();
intent = new Intent(Intent.ActionGetContent);
intent.SetType("image/*");
try
{
Xamarin.Forms.Forms.Context.PackageManager.GetPackageInfo("com.android.gallery", 0);
intent.SetPackage("com.android.gallery");
}
catch { }
this.StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), SELECT_FILE);
And here's how I grab the Uri in OnActivityResult after image selection:
public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
ContentResolver resolver = this.Activity.ContentResolver;
if (resultCode == Result.Ok && requestCode == SELECT_FILE)
{
ImageUri = data.Data;
}
}
So I'm going nuts trying to work out why data.Data is null only on a select few devices, namely Samsung Galaxy S7.