移动云

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 11664|回复: 0

浅析PowerManager里方法userActivity

[复制链接]
发表于 2012-2-15 16:02:08 | 显示全部楼层 |阅读模式
先看接口定义
public void userActivity (long when, boolean noChangeLights)
Since: API Level 1 User activity happened.
Turns the device from whatever state it's in to full on, and resets the auto-off timer.
Parameters
when  is used to order this correctly with the wake lock calls. This time should be in the SystemClock.uptimeMillis() time base.
noChangeLights  should be true if you don't want the lights to turn on because of this event. This is set when the power key goes down. We want the device to stay on while the button is down, but we're about to turn off. Otherwise the lights flash on and then off and it looks weird.  
这个方法在我们抓了wakeup锁释放后希望切换成系统设置的显示超时时间时用到。
锁屏里用到了这个方法:
在进入锁屏界面的时候LockScreen抓了一个带超时的锁,超时后,在用户没有任何动作的情况下释放锁从而灭屏。
在用户解锁的时候LockScreen调用了userActivity(SystemClock.uptimeMillis, true)然后释放锁,从而重设了系统auto-off的时间。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|管理员QQ:44994224|邮箱(t268studio@gmail.com)|Archiver|MCLOUDER

GMT+8, 2025-7-2 05:38 , Processed in 0.037421 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表