Issue
I'm building a Custom Control (a Gallery Picture Picker)
basically trying to re-make a this : Microsoft.Maui.Media.MediaPicker.PickPhotoAsync()
but i didn't find anyway to retrieve user pictures on MAUI ..
on Xamarin.Android i used this code :
var uriExternal = MediaStore.Images.Media.ExternalContentUri;
string[] projection = { (MediaStore.Images.Media.InterfaceConsts.Id),
(MediaStore.Images.Media.InterfaceConsts.DateAdded),
(MediaStore.Images.Media.InterfaceConsts.RelativePath) };
var cursor = Android.App.Application.Context.ContentResolver.Query(uriExternal, projection, null, null, MediaStore.Images.Media.InterfaceConsts.DateAdded);
if (cursor != null) {
int columnIndexID = cursor.GetColumnIndexOrThrow(MediaStore.Images.Media.InterfaceConsts.Id);
int RelativePathID = cursor.GetColumnIndexOrThrow(MediaStore.Images.Media.InterfaceConsts.RelativePath);
while (cursor.MoveToNext()) {
long imageId = cursor.GetLong(columnIndexID);
string rPath = cursor.GetString(RelativePathID);
//Get the Picture's URI
Android.Net.Uri uriImage = Android.Net.Uri.WithAppendedPath(uriExternal, "" + imageId);
...
}
}
with this Code, given the required permissions, i could get the external path of all pictures of an Android phone to then use them in my PicturePicking custom control ..
==> how can i do this in Microsoft MAUI !! (targeting Android & IOS)
(just to be clear, of course i know that i could just use MediaPicker's [PickPhotoAsync] function, but i clearly don't want that, it's not an option)
Thanks in advance for any help !
Solution
So after 2 days of searching.. i've came to the conclusion that the only way to do this is by using Plateform Specific Code ..
(i tryed it successfully)
Answered By - Robert258
Answer Checked By - Senaida (JavaFixing Volunteer)