DevicePolicyManager.ClearPackagePersistentPreferredActivities Method

Definition

Called by a profile owner or device owner or holder of the permission android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_TASK to remove all persistent intent handler preferences associated with the given package that were set by #addPersistentPreferredActivity.

[Android.Runtime.Register("clearPackagePersistentPreferredActivities", "(Landroid/content/ComponentName;Ljava/lang/String;)V", "GetClearPackagePersistentPreferredActivities_Landroid_content_ComponentName_Ljava_lang_String_Handler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_LOCK_TASK")]
public virtual void ClearPackagePersistentPreferredActivities (Android.Content.ComponentName? admin, string? packageName);
[<Android.Runtime.Register("clearPackagePersistentPreferredActivities", "(Landroid/content/ComponentName;Ljava/lang/String;)V", "GetClearPackagePersistentPreferredActivities_Landroid_content_ComponentName_Ljava_lang_String_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_LOCK_TASK")>]
abstract member ClearPackagePersistentPreferredActivities : Android.Content.ComponentName * string -> unit
override this.ClearPackagePersistentPreferredActivities : Android.Content.ComponentName * string -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with. Null if the caller is not a device admin.

packageName
String

The name of the package for which preferences are removed.

Attributes

Remarks

Called by a profile owner or device owner or holder of the permission android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_TASK to remove all persistent intent handler preferences associated with the given package that were set by #addPersistentPreferredActivity.

The calling device admin must be a profile owner. If it is not, a security exception will be thrown.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, after the persistent preferred activity policy has been cleared, PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin on whether the policy was successfully cleared or not. This callback will contain: <ul> <li> The policy identifier DevicePolicyIdentifiers#PERSISTENT_PREFERRED_ACTIVITY_POLICY<li> The additional policy params bundle, which contains PolicyUpdateReceiver#EXTRA_INTENT_FILTER the intent filter the policy applies to <li> The TargetUser that this policy relates to <li> The PolicyUpdateResult, which will be PolicyUpdateResult#RESULT_POLICY_SET if the policy was successfully cleared or the reason the policy failed to be cleared (e.g. PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY) </ul> If there has been a change to the policy, PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin of this change. This callback will contain the same parameters as PolicyUpdateReceiver#onPolicySetResult and the PolicyUpdateResult will contain the reason why the policy changed.

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