Android 10.0实现屏幕10s无操作自动播放视频

在定制化广告机项目中,需要不间断的播放视频,当对屏幕没有操作时继续播放视频,对于这个功能,
在app中,可以通过onTouch事件来判断手势抬起后倒计时10s无操作时然后播放视频,但是对于系统而言就难判断屏幕是否操作了

查阅资料和请教其他大佬得知,在PowerManagerService.java中有对操作屏幕做了记录时间

/**
 * Updates the value of mUserActivitySummary to summarize the user requested
 * state of the system such as whether the screen should be bright or dim.
 * Note that user activity is ignored when the system is asleep.
 *
 * This function must have no other side-effects.
 */
private void updateUserActivitySummaryLocked(long now, int dirty) {
   
    
    
    // Update the status of the user activity timeout timer.
    if 

猜你喜欢

转载自blog.csdn.net/baidu_41666295/article/details/123438038