jamesmontemagno / Xamarin.Plugins

Cross-platform Native API Access from Shared Code!
MIT License
1.3k stars 380 forks source link

PickPhotoAsync problem on Android 5.1.1 #240

Closed apivovar closed 8 years ago

apivovar commented 8 years ago

This is a

Which plugin does this impact:

Version Number of Plugin: 2.3.0, 2.4.0-beta2 Device Tested On: Android 5.1.1 (Nexus 4) Simulator Tested On:

Expected Behavior

It should show Gallery image picker at least. However it does nothing, because of the exception caught in MediaPickerActivity.cs file:

No Activity found to handle Intent act=android.intent.action.PICK typ=image

Looks like this issue is reproduced since Android Lollipop.

Actual Behavior

await CrossMedia.Current.PickPhotoAsync() returns null

How to fix

Please, replace Intent.ActionPick with Intent.ActionGetContent all over the code of the plugin (MediaImplementation.cs and MediaPickerActivity.cs files). ACTION_GET_CONTENT provides more useful user interface.

Vandersteen commented 8 years ago

I had a similar issue with TakePhotoAsync. Turns out the permissions wheren't set / asked for (in my case).

Using:

var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
    await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera);

    var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] {Permission.Camera});
    status = results[Permission.Camera];
}

if (status == PermissionStatus.Granted)
{
... use take photo here
}

Solved it on my part.

jamesmontemagno commented 8 years ago

This issue was moved to jamesmontemagno/MediaPlugin#21