PackageManager.GetEnableAppLockIntentForPackage(String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a PendingIntent to launch an Activity that allows the caller to
set App Lock for the specified package.
[Android.Runtime.Register("getEnableAppLockIntentForPackage", "(Ljava/lang/String;Z)Landroid/app/PendingIntent;", "GetGetEnableAppLockIntentForPackage_Ljava_lang_String_ZHandler", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.LOCK_APPS")]
public virtual Android.App.PendingIntent? GetEnableAppLockIntentForPackage(string packageName, bool enabled);
[<Android.Runtime.Register("getEnableAppLockIntentForPackage", "(Ljava/lang/String;Z)Landroid/app/PendingIntent;", "GetGetEnableAppLockIntentForPackage_Ljava_lang_String_ZHandler", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.LOCK_APPS")>]
abstract member GetEnableAppLockIntentForPackage : string * bool -> Android.App.PendingIntent
override this.GetEnableAppLockIntentForPackage : string * bool -> Android.App.PendingIntent
Parameters
- packageName
- String
the package to enable or disable App Lock.
- enabled
- Boolean
true when the user would like to enable App Lock for the given package, false otherwise
Returns
a PendingIntent to launch an activity to set App Lock for the passed in
package. If the package does not support App Lock or the package's App Lock state is
already in the passed in state, return null.
- Attributes
Remarks
Returns a PendingIntent to launch an Activity that allows the caller to set App Lock for the specified package. Returns null if the App Lock state of the package cannot be set, either because App Lock is not supported for that package, or because it is already set to that value.
App Lock is a feature that allows users to add authentication as a requirement to open individual apps, even if the device is unlocked. When App Lock is enabled for an app, the system performs the following protections:
Requires authentication using device credentials (e.g. PIN, pattern, or password) or Class 3 biometrics, whenever the user attempts to open the app (including after reinstallation), or share information to it via the Sharesheet.
Redacts sensitive content of notifications sent by the app.
Removes the app's widgets and shortcuts from the home screen.
Displays a locked view of the app in Recents to prevent content leakage.
Hides the app's Direct Share targets from the Sharesheet.
Once authenticated, an App Lock enabled app remains unlocked while it is visible in the foreground. The app will remain unlocked for a short grace period after the user navigates away, after which the system will re-lock it. Additionally, all App Lock enabled apps are immediately locked whenever the device is locked.
Before calling this API to avoid getting a null PendingIntent callers should first verify that App Lock is supported for the specified package by first checking ApplicationInfo.isAppLockSupported, or if it's already at the target state for that package by checking ApplicationInfo.isAppLockEnabled. The PendingIntent resolves to an activity, which allows the user to enroll a device credential if one isn't enrolled, and then requires authentication before setting the App Lock enablement state as enabled or disabled. Requires Manifest.permission.LOCK_APPS
Android reference for android.content.pm.PackageManager.getEnableAppLockIntentForPackage.
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.