I am having trouble trying to select photos on Android. I am using the code below to launch the activity.
var intent = new Intent ();
intent.SetType ("video/*");
intent.SetAction (Intent.ActionGetContent);
intent.PutExtra (MediaStore.ExtraVideoQuality, 0);
intent.PutExtra (MediaStore.ExtraDurationLimit, Globals.VideoMaxDuration);
this.StartActivityForResult (Intent.CreateChooser (intent, "Select video"), 200);
Then in the OnActivityResult callback I use the following code to get the URI of the data.
if (resultCode == Result.Ok && data.Data != null)
{
String[] proj = { MediaStore.Images.Media.InterfaceConsts.Data };
ICursor cursor = this.ContentResolver.Query(data.Data, proj, null, null, null);
int colIndex = cursor.GetColumnIndexOrThrow (MediaStore.Video.Media.InterfaceConsts.Data);
cursor.MoveToFirst ();
vid = cursor.GetString(colIndex);
// do stuff with vid
}
This works great when choosing videos from the "gallery" option, but when I try to select a video from the "recent" or "download" sections of the chooser the VID is always null.
Does anyone have any idea how to get video data from the video chooser intent reliably? Also, the code is in C# as this is an Monotouch (Xamarin) app, but I have created a test app in native Android and have the exact same issue.
Thanks!