简体   繁体   English

WakeLock.release()会关闭屏幕,即使用户正在与应用程序进行交互

[英]WakeLock.release() switches off screen even if the user was interacting with the app

My app wakes the phone from standby and turns on the screen ( SCREEN_BRIGHT_WAKE_LOCK ). 我的应用程序将手机从待机状态唤醒,并打开了屏幕( SCREEN_BRIGHT_WAKE_LOCK )。 I can't use the WindowManager-flags approach, as my app may already be running in the background. 我不能使用WindowManager-flags方法,因为我的应用程序可能已经在后台运行。

The problem is that once the user dismisses my app and the WakeLock is released, the screen turns off immediately, even if the user was interacting with the app (or the homescreen, which briefly shows while the app is being closed). 问题在于,一旦用户关闭了我的应用程序并释放了WakeLock,即使用户正在与该应用程序进行交互(或在关闭该应用程序时短暂显示的主屏幕),屏幕也会立即关闭。

Would using the ON_AFTER_RELEASE -flag help? 使用ON_AFTER_RELEASE -flag帮助吗?

Yes, you want to use the ON_AFTER_RELEASE flag. 是的,您想使用ON_AFTER_RELEASE标志。

When this wake lock is released, poke the user activity timer so the screen stays on for a little longer. 释放此唤醒锁后,请拨动用户活动计时器,以使屏幕停留一会儿。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用wakelock.release()关闭应用程序时Android应用程序崩溃 - Android app crashed when closing app using wakelock.release() 屏幕关闭时释放WAKELOCK - Release WAKELOCK when screen is off 为什么我不能调用wakeLock.release(); 从处理程序? - why can't I call wakeLock.release(); from a handler? 是否必须始终达到每个WakeLock.release()调用? Android的皮棉警告 - Must every WakeLock.release() call always be reached? android lint warning 即使用户切换应用程序,CountDownTimer也会运行 - CountDownTimer running even when user switches app 即使使用WakeLock,当Droid / Nexus One屏幕关闭时,Accelerometer也会停止提供样品 - Accelerometer stops delivering samples when the screen is off on Droid/Nexus One even with a WakeLock 屏幕关闭时,Android Wakelock无法正常工作 - Android Wakelock not working when screen is off WakeLock没有释放且屏幕没有关闭 - WakeLock not releasing and Screen isn't turning off 使用部分唤醒锁关闭屏幕时阻止应用程序进入OnPause - Prevent app from going on OnPause when turning screen off using partial wakelock 即使退出应用程序后,也可以针对SCREEN_ON和SCREEN_OFF使用BroadcastReceiver - BroadcastReceiver for SCREEN_ON and SCREEN_OFF even after quitting the app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM