Dela via


UserManager.IsUserRunning(UserHandle) Method

Definition

Return whether the given user is actively running.

[Android.Runtime.Register("isUserRunning", "(Landroid/os/UserHandle;)Z", "GetIsUserRunning_Landroid_os_UserHandle_Handler")]
public virtual bool IsUserRunning (Android.OS.UserHandle? user);
[<Android.Runtime.Register("isUserRunning", "(Landroid/os/UserHandle;)Z", "GetIsUserRunning_Landroid_os_UserHandle_Handler")>]
abstract member IsUserRunning : Android.OS.UserHandle -> bool
override this.IsUserRunning : Android.OS.UserHandle -> bool

Parameters

user
UserHandle

The user to retrieve the running state for.

Returns

Attributes

Remarks

Return whether the given user is actively running. This means that the user is in the "started" state, not "stopped" -- it is currently allowed to run code through scheduled alarms, receiving broadcasts, etc. A started user may be either the current foreground user or a background user; the result here does not distinguish between the two.

Note prior to Android Nougat MR1 (SDK version <= 24; android.os.Build.VERSION_CODES#N, this API required a system permission in order to check other profile's status. Since Android Nougat MR1 (SDK version >= 25; android.os.Build.VERSION_CODES#N_MR1), the restriction has been relaxed, and now it'll accept any android.os.UserHandle within the same profile group as the caller.

Java documentation for android.os.UserManager.isUserRunning(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