ActivityOptions.SetLockTaskEnabled(Boolean) Method

Definition

Sets whether the activity is to be launched into LockTask mode.

[Android.Runtime.Register("setLockTaskEnabled", "(Z)Landroid/app/ActivityOptions;", "GetSetLockTaskEnabled_ZHandler", ApiSince=28)]
public virtual Android.App.ActivityOptions? SetLockTaskEnabled (bool lockTaskMode);
[<Android.Runtime.Register("setLockTaskEnabled", "(Z)Landroid/app/ActivityOptions;", "GetSetLockTaskEnabled_ZHandler", ApiSince=28)>]
abstract member SetLockTaskEnabled : bool -> Android.App.ActivityOptions
override this.SetLockTaskEnabled : bool -> Android.App.ActivityOptions

Parameters

lockTaskMode
Boolean

true if the activity is to be launched into LockTask mode.

Returns

this ActivityOptions instance.

Attributes

Remarks

Sets whether the activity is to be launched into LockTask mode.

Use this option to start an activity in LockTask mode. Note that only apps permitted by android.app.admin.DevicePolicyManager can run in LockTask mode. Therefore, if android.app.admin.DevicePolicyManager#isLockTaskPermitted(String) returns false for the package of the target activity, a SecurityException will be thrown during Context#startActivity(Intent, Bundle). This method doesn't affect activities that are already running — relaunch the activity to run in lock task mode.

Defaults to false if not set.

Java documentation for android.app.ActivityOptions.setLockTaskEnabled(boolean).

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