DevicePolicyManager.SetPermissionPolicy Method

Definition

Set the default response for future runtime permission requests by applications.

[Android.Runtime.Register("setPermissionPolicy", "(Landroid/content/ComponentName;I)V", "GetSetPermissionPolicy_Landroid_content_ComponentName_IHandler", ApiSince=23)]
public virtual void SetPermissionPolicy (Android.Content.ComponentName admin, Android.App.Admin.PermissionPolicy policy);
[<Android.Runtime.Register("setPermissionPolicy", "(Landroid/content/ComponentName;I)V", "GetSetPermissionPolicy_Landroid_content_ComponentName_IHandler", ApiSince=23)>]
abstract member SetPermissionPolicy : Android.Content.ComponentName * Android.App.Admin.PermissionPolicy -> unit
override this.SetPermissionPolicy : Android.Content.ComponentName * Android.App.Admin.PermissionPolicy -> unit

Parameters

admin
ComponentName

Which profile or device owner this request is associated with.

policy
PermissionPolicy

One of the policy constants #PERMISSION_POLICY_PROMPT, #PERMISSION_POLICY_AUTO_GRANT and #PERMISSION_POLICY_AUTO_DENY.

Attributes

Remarks

Set the default response for future runtime permission requests by applications. This function can be called by a device owner, profile owner, or by a delegate given the #DELEGATION_PERMISSION_GRANT scope via #setDelegatedScopes. The policy can allow for normal operation which prompts the user to grant a permission, or can allow automatic granting or denying of runtime permission requests by an application. This also applies to new permissions declared by app updates. When a permission is denied or granted this way, the effect is equivalent to setting the permission * grant state via #setPermissionGrantState. <p/> As this policy only acts on runtime permission requests, it only applies to applications built with a targetSdkVersion of android.os.Build.VERSION_CODES#M or later.

NOTE: On devices running android.os.Build.VERSION_CODES#S and above, an auto-grant policy will not apply to certain sensors-related permissions on some configurations. See #setPermissionGrantState(ComponentName, String, String, int) for the list of permissions affected, and the behavior change for managed profiles and fully-managed devices.

Java documentation for android.app.admin.DevicePolicyManager.setPermissionPolicy(android.content.ComponentName, 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