Share via


Context.RevokeSelfPermissionsOnKill(ICollection<String>) Method

Definition

Triggers the revocation of one or more permissions for the calling package.

[Android.Runtime.Register("revokeSelfPermissionsOnKill", "(Ljava/util/Collection;)V", "GetRevokeSelfPermissionsOnKill_Ljava_util_Collection_Handler", ApiSince=33)]
public virtual void RevokeSelfPermissionsOnKill (System.Collections.Generic.ICollection<string> permissions);
[<Android.Runtime.Register("revokeSelfPermissionsOnKill", "(Ljava/util/Collection;)V", "GetRevokeSelfPermissionsOnKill_Ljava_util_Collection_Handler", ApiSince=33)>]
abstract member RevokeSelfPermissionsOnKill : System.Collections.Generic.ICollection<string> -> unit
override this.RevokeSelfPermissionsOnKill : System.Collections.Generic.ICollection<string> -> unit

Parameters

permissions
ICollection<String>

Collection of permissions to be revoked.

Attributes

Remarks

Triggers the revocation of one or more permissions for the calling package. A package is only able to revoke runtime permissions. If a permission is not currently granted, it is ignored and will not get revoked (even if later granted by the user). Ultimately, you should never make assumptions about a permission status as users may grant or revoke them at any time.

Background permissions which have no corresponding foreground permission still granted once the revocation is effective will also be revoked.

The revocation happens asynchronously and kills all processes running in the calling UID. It will be triggered once it is safe to do so. In particular, it will not be triggered as long as the package remains in the foreground, or has any active manifest components (e.g. when another app is accessing a content provider in the package).

If you want to revoke the permissions right away, you could call System.exit(), but this could affect other apps that are accessing your app at the moment. For example, apps accessing a content provider in your app will all crash.

Note that the settings UI shows a permission group as granted as long as at least one permission in the group is granted. If you want the user to observe the revocation in the settings, you should revoke every permission in the target group. To learn the current list of permissions in a group, you may use PackageManager#getGroupOfPlatformPermission(String, Executor, Consumer) and PackageManager#getPlatformPermissionsForGroup(String, Executor, Consumer). This list of permissions may evolve over time, so it is recommended to check whether it contains any permission you wish to retain before trying to revoke an entire group.

Java documentation for android.content.Context.revokeSelfPermissionsOnKill(java.util.Collection<java.lang.String>).

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