Partager via


Context.RevokeUriPermission Method

Definition

Overloads

RevokeUriPermission(Uri, ActivityFlags)

Remove all permissions to access a particular content provider Uri that were previously added with #grantUriPermission or <em>any other</em> mechanism.

RevokeUriPermission(String, Uri, ActivityFlags)

Remove permissions to access a particular content provider Uri that were previously added with #grantUriPermission for a specific target package.

RevokeUriPermission(Uri, ActivityFlags)

Remove all permissions to access a particular content provider Uri that were previously added with #grantUriPermission or <em>any other</em> mechanism.

[Android.Runtime.Register("revokeUriPermission", "(Landroid/net/Uri;I)V", "GetRevokeUriPermission_Landroid_net_Uri_IHandler")]
public abstract void RevokeUriPermission (Android.Net.Uri? uri, Android.Content.ActivityFlags modeFlags);
[<Android.Runtime.Register("revokeUriPermission", "(Landroid/net/Uri;I)V", "GetRevokeUriPermission_Landroid_net_Uri_IHandler")>]
abstract member RevokeUriPermission : Android.Net.Uri * Android.Content.ActivityFlags -> unit

Parameters

uri
Uri

The Uri you would like to revoke access to.

modeFlags
ActivityFlags

The access modes to revoke.

Attributes

Remarks

Remove all permissions to access a particular content provider Uri that were previously added with #grantUriPermission or <em>any other</em> mechanism. The given Uri will match all previously granted Uris that are the same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will not remove any prefix grants that exist at a higher level.

Prior to android.os.Build.VERSION_CODES#LOLLIPOP, if you did not have regular permission access to a Uri, but had received access to it through a specific Uri permission grant, you could not revoke that grant with this function and a SecurityException would be thrown. As of android.os.Build.VERSION_CODES#LOLLIPOP, this function will not throw a security exception, but will remove whatever permission grants to the Uri had been given to the app (or none).

Unlike #revokeUriPermission(String, Uri, int), this method impacts all permission grants matching the given Uri, for any package they had been granted to, through any mechanism this had happened (such as indirectly through the clipboard, activity launch, service start, etc). That means this can be potentially dangerous to use, as it can revoke grants that another app could be strongly expecting to stick around.

Java documentation for android.content.Context.revokeUriPermission(android.net.Uri, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

  • <xref:Android.Content.Context.GrantUriPermission(System.String%2c+Android.Net.Uri%2c+Android.Net.Uri)>

Applies to

RevokeUriPermission(String, Uri, ActivityFlags)

Remove permissions to access a particular content provider Uri that were previously added with #grantUriPermission for a specific target package.

[Android.Runtime.Register("revokeUriPermission", "(Ljava/lang/String;Landroid/net/Uri;I)V", "GetRevokeUriPermission_Ljava_lang_String_Landroid_net_Uri_IHandler", ApiSince=26)]
public abstract void RevokeUriPermission (string? toPackage, Android.Net.Uri? uri, Android.Content.ActivityFlags modeFlags);
[<Android.Runtime.Register("revokeUriPermission", "(Ljava/lang/String;Landroid/net/Uri;I)V", "GetRevokeUriPermission_Ljava_lang_String_Landroid_net_Uri_IHandler", ApiSince=26)>]
abstract member RevokeUriPermission : string * Android.Net.Uri * Android.Content.ActivityFlags -> unit

Parameters

toPackage
String

The package you had previously granted access to.

uri
Uri

The Uri you would like to revoke access to.

modeFlags
ActivityFlags

The access modes to revoke.

Attributes

Remarks

Remove permissions to access a particular content provider Uri that were previously added with #grantUriPermission for a specific target package. The given Uri will match all previously granted Uris that are the same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will not remove any prefix grants that exist at a higher level.

Unlike #revokeUriPermission(Uri, int), this method will <em>only</em> revoke permissions that had been explicitly granted through #grantUriPermission and only for the package specified. Any matching grants that have happened through other mechanisms (clipboard, activity launching, service starting, etc) will not be removed.

Java documentation for android.content.Context.revokeUriPermission(java.lang.String, android.net.Uri, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to