I was looking at some examples which fire an android.media.action.IMAGE_CAPTURE
intent and use a class-level variable to store the resulting image. I don't want to do that. I think I should be able to give the intent the URI of the file and then get that URI back from the intent when it completes. I am trying to do this:
void snapPixButton_Click(object sender, EventArgs e)
{
Intent cameraIntent = new Intent(MediaStore.ActionImageCapture);
File file = new File(Home.SnapStorageLocation, string.Format("{0}.jpg", Guid.NewGuid()));
cameraIntent.PutExtra(MediaStore.ExtraOutput, file.ToURI().ToString());
StartActivityForResult(cameraIntent, SnapPixIntentRequestCode);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (requestCode == SnapPixIntentRequestCode && resultCode == Result.Ok)
{
URI uri = new URI(data.GetStringExtra(MediaStore.ExtraOutput));
File file = new File(uri);
using (Bitmap bitmap = LoadAndResizeBitmap(file.Path, this.ImageView.Width, this.ImageView.Height))
{
this.ImageView.SetImageBitmap(bitmap);
}
}
}
But in OnActivityResult
, the call to data.GetStringExtra(MediaStore.ExtraOutput)
results in the message: Unknown identifier: MediaStore
What am I doing wrong? I don't think I should have to keep class-level variables around, I should be able to pass data to an intent and then extract it afterwards, right?