Activity.StartLockTask Method

Definition

Request to put this activity in a mode where the user is locked to a restricted set of applications.

[Android.Runtime.Register("startLockTask", "()V", "GetStartLockTaskHandler")]
public virtual void StartLockTask ();
[<Android.Runtime.Register("startLockTask", "()V", "GetStartLockTaskHandler")>]
abstract member StartLockTask : unit -> unit
override this.StartLockTask : unit -> unit
Attributes

Remarks

Request to put this activity in a mode where the user is locked to a restricted set of applications.

If DevicePolicyManager#isLockTaskPermitted(String) returns true for this component, the current task will be launched directly into LockTask mode. Only apps allowlisted by DevicePolicyManager#setLockTaskPackages(ComponentName, String[]) can be launched while LockTask mode is active. The user will not be able to leave this mode until this activity calls #stopLockTask(). Calling this method while the device is already in LockTask mode has no effect.

Otherwise, the current task will be launched into screen pinning mode. In this case, the system will prompt the user with a dialog requesting permission to use this mode. The user can exit at any time through instructions shown on the request dialog. Calling #stopLockTask() will also terminate this mode.

<strong>Note:</strong> this method can only be called when the activity is foreground. That is, between #onResume() and #onPause().

Java documentation for android.app.Activity.startLockTask().

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