Android.Content.ContextWrapper.GrantUriPermission Method
Grant permission to access a specific Uri to another package, regardless of whether that package has general permission to access the Uri's content provider.

Syntax

[Android.Runtime.Register("grantUriPermission", "(Ljava/lang/String;Landroid/net/Uri;I)V", "GetGrantUriPermission_Ljava_lang_String_Landroid_net_Uri_IHandler")]
public override void GrantUriPermission (string toPackage, Android.Net.Uri uri, [Android.Runtime.GeneratedEnum] ActivityFlags modeFlags)

Parameters

toPackage
The package you would like to allow to access the Uri.
uri
The Uri you would like to grant access to.
modeFlags
The desired access modes. Any combination of Intent.FLAG_GRANT_READ_URI_PERMISSION, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, or Intent.FLAG_GRANT_PREFIX_URI_PERMISSION.

Remarks

Grant permission to access a specific Uri to another package, regardless of whether that package has general permission to access the Uri's content provider. This can be used to grant specific, temporary permissions, typically in response to user interaction (such as the user opening an attachment that you would like someone else to display).

Normally you should use Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION with the Intent being used to start an activity instead of this function directly. If you use this function directly, you should be sure to call Context.RevokeUriPermission(Android.Net.Uri, Android.Content.ActivityFlags) when the target should no longer be allowed to access it.

To succeed, the content provider owning the Uri must have set the NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestProvider_grantUriPermissions attribute in its manifest or included the NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestGrantUriPermission tag.

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1