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

FilePicker Plugin for Xamarin and Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add TakePersistableUriPermission

Mike134 opened this issue · comments

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);
}

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

@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!

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