共用方式為


PowerManager.UserActivity(Int64, Boolean) Method

Definition

Notifies the power manager that user activity happened.

[Android.Runtime.Register("userActivity", "(JZ)V", "GetUserActivity_JZHandler")]
public virtual void UserActivity (long when, bool noChangeLights);
[<Android.Runtime.Register("userActivity", "(JZ)V", "GetUserActivity_JZHandler")>]
abstract member UserActivity : int64 * bool -> unit
override this.UserActivity : int64 * bool -> unit

Parameters

when
Int64

The time of the user activity, in the SystemClock#uptimeMillis() time base. This timestamp is used to correctly order the user activity request with other power management functions. It should be set to the timestamp of the input event that caused the user activity.

noChangeLights
Boolean

If true, does not cause the keyboard backlight to turn on because of this event. This is set when the power key is pressed. We want the device to stay on while the button is down, but we're about to turn off the screen so we don't want the keyboard backlight to turn on again. Otherwise the lights flash on and then off and it looks weird.

Attributes

Remarks

Notifies the power manager that user activity happened.

Resets the auto-off timer and brightens the screen if the device is not asleep. This is what happens normally when a key or the touch screen is pressed or when some other user activity occurs. This method does not wake up the device if it has been put to sleep.

Requires the android.Manifest.permission#DEVICE_POWER permission.

This member is deprecated. Use #userActivity(long, int, int).

Java documentation for android.os.PowerManager.userActivity(long, 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

See also