Freigeben über


DevicePolicyManager.SetLockTaskFeatures Method

Definition

Sets which system features are enabled when the device runs in lock task mode.

[Android.Runtime.Register("setLockTaskFeatures", "(Landroid/content/ComponentName;I)V", "GetSetLockTaskFeatures_Landroid_content_ComponentName_IHandler", ApiSince=28)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_LOCK_TASK")]
public virtual void SetLockTaskFeatures (Android.Content.ComponentName? admin, Android.App.Admin.LockTaskFeatures flags);
[<Android.Runtime.Register("setLockTaskFeatures", "(Landroid/content/ComponentName;I)V", "GetSetLockTaskFeatures_Landroid_content_ComponentName_IHandler", ApiSince=28)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_LOCK_TASK")>]
abstract member SetLockTaskFeatures : Android.Content.ComponentName * Android.App.Admin.LockTaskFeatures -> unit
override this.SetLockTaskFeatures : Android.Content.ComponentName * Android.App.Admin.LockTaskFeatures -> unit

Parameters

admin
ComponentName

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

flags
LockTaskFeatures

The system features enabled during lock task mode.

Attributes

Remarks

Sets which system features are enabled when the device runs in lock task mode. This method doesn't affect the features when lock task mode is inactive. Any system features not included in flags are implicitly disabled when calling this method. By default, only #LOCK_TASK_FEATURE_GLOBAL_ACTIONS is enabled; all the other features are disabled. To disable the global actions dialog, call this method omitting #LOCK_TASK_FEATURE_GLOBAL_ACTIONS.

This method can only be called by the device owner, a profile owner of an affiliated user or profile, or the profile owner when no device owner is set or holders of the permission android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_TASK. See #isAffiliatedUser. Any features set using this method are cleared if the user becomes unaffiliated.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, after the lock task features policy has been set, PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, PolicyUpdateResult) will notify the admin on whether the policy was successfully set or not. This callback will contain: <ul> <li> The policy identifier DevicePolicyIdentifiers#LOCK_TASK_POLICY<li> The TargetUser that this policy relates to <li> The PolicyUpdateResult, which will be PolicyUpdateResult#RESULT_POLICY_SET if the policy was successfully set or the reason the policy failed to be set (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.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, lock task features and lock task packages are bundled as one policy. A failure to apply one will result in a failure to apply the other.

Java documentation for android.app.admin.DevicePolicyManager.setLockTaskFeatures(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