Now that we have created an implementation for iOS, we will do the same for Android:
- Create a new interface named PhotoImporter in the GalleryApp.Android project.
- Import all the members from the IPhotoImporter interface.
- Resolve all the references.
- Create a new method named ContinueWithPermission, which we will call when we get permission from the user to get photos from the photo gallery.
- Use ContentResolver to get the photos (as in the following code block).
- Loop through the result and add it to a class-level field with a string[] type named result:
public class PhotoImporter : IPhotoImporter
{
private bool hasCheckedPermission;
private string[] result;
public bool ContinueWithPermission(bool granted)
{
if (!granted)
{
return false;
}
Android.Net.Uri imageUri =
MediaStore.Images.Media.ExternalContentUri;
var cursor =
...