jfversluis / FilePicker-Plugin-for-Xamarin-and-Windows

FilePicker Plugin for Xamarin and Windows
MIT License
157 stars 80 forks source link

Add TakePersistableUriPermission #158

Closed Mike134 closed 4 years ago

Mike134 commented 5 years ago

Would like for the FilePicker in Android to persist permissions after a file has been successfully selected.

I'm wondering if in FilePickerActivity.android.cs, in OnActivityResult at around line 153 adding something similar to the following would do the trick.

if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat)                
{
    context.ContentResolver.TakePersistableUriPermission(uUri, ActivityFlags.GrantWriteUriPermission | ActivityFlags.GrantReadUriPermission);
}
vividos commented 4 years ago

I tried to put this in the FilePicker, but calling TakePersistableUriPermission() throws a SecurityException...

vividos commented 4 years ago

@Mike134 figured it out; see PR #178. Could you test with the latest FilePicker NuGet, 2.1.41-beta, if the error that you found is fixed? Thanks!

vividos commented 4 years ago

calling TakePersistableUriPermisssion is now in since some time. I'm closing this issue.