共用方式為


LauncherApps.IsPackageEnabled(String, UserHandle) Method

Definition

Checks if the package is installed and enabled for a profile.

[Android.Runtime.Register("isPackageEnabled", "(Ljava/lang/String;Landroid/os/UserHandle;)Z", "GetIsPackageEnabled_Ljava_lang_String_Landroid_os_UserHandle_Handler")]
public virtual bool IsPackageEnabled (string? packageName, Android.OS.UserHandle? user);
[<Android.Runtime.Register("isPackageEnabled", "(Ljava/lang/String;Landroid/os/UserHandle;)Z", "GetIsPackageEnabled_Ljava_lang_String_Landroid_os_UserHandle_Handler")>]
abstract member IsPackageEnabled : string * Android.OS.UserHandle -> bool
override this.IsPackageEnabled : string * Android.OS.UserHandle -> bool

Parameters

packageName
String

The package to check.

user
UserHandle

The UserHandle of the profile.

Returns

true if the package exists and is enabled.

Attributes

Remarks

Checks if the package is installed and enabled for a profile.

If the user in question is a hidden profile UserManager.USER_TYPE_PROFILE_PRIVATE, caller should have either:

<ul> <li>the privileged android.Manifest.permission.ACCESS_HIDDEN_PROFILES_FULL permission</li> <li>the normal android.Manifest.permission.ACCESS_HIDDEN_PROFILES permission and the android.app.role.RoleManager.ROLE_HOME role. </li> </ul>

Java documentation for android.content.pm.LauncherApps.isPackageEnabled(java.lang.String, android.os.UserHandle).

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