Reputation: 3119
I am trying to call the camera, with certain arguments, along with some extra data my activity needs to process the returned photo , I used this code:
Intent intent = new Intent(MediaStore.ActionImageCapture);
Java.IO.File file = new Java.IO.File(System.IO.Path.Combine(App.DatabaseFolder, ATTACHMENT_FILE));
intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file));
intent.PutExtra(MediaStore.ExtraScreenOrientation, (int)ScreenOrientation.Portrait);
intent.PutExtra("source_id", id); // here I put the extra data
StartActivityForResult(intent, CAMERA_INTENT_REQUEST);
now I am trying to retrieve the id sent to the activity when the result comes back
is there a way to do that? I tried
if (requestCode = CAMERA_INTENT_REQUEST && resultCode == Result.Ok) {
data.GetIntExtra("source_id", -1);
}
but I can't seem to retrieve the result
as a workaround I managed to do the above by either saving the id in the result code or the file name, but I prefer to find another way, is there one?
In case you find the code weird, it is written in Xamarin Android, but it's still an android question
thanks in advance for any help you can provide
Upvotes: 0
Views: 282
Reputation: 1136
You can't do that. Camera is an external application and don't collect your "extra info".
More info here : AndroidDeveloer - Camera API
So in your case you should store your id into a global variable or SharedPreferences
Upvotes: 1