弃用 SCREEN_BRIGHT_WAKE_LOCK 后,如何在 Wear OS 中保持屏幕打开?

发布于 2025-01-16 20:13:29 字数 142 浏览 1 评论 0原文

对于我的 Wear OS 表盘项目,我使用标志 SCREEN_BRIGHT_WAKE_LOCK 来获取唤醒锁,使屏幕完全打开一分钟(由用户根据需要触发)。该标志已被弃用。标志 PARTIAL_WAKE_LOCK 仍然有效,但不会保持屏幕打开。现在这样做的正确方法是什么?

For my Wear OS watch face project, I was using the flag SCREEN_BRIGHT_WAKE_LOCK to acquire a wakelock that keeps the screen fully on for one minute (triggered by the user as needed). This flag has been deprecated. The flag PARTIAL_WAKE_LOCK is still valid, but does not keep the screen on. What is the correct way to do this now?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惟欲睡 2025-01-23 20:13:29

我相信手表可以控制这一点,并且通常是用户设置来启用“始终显示”。即使在这种模式下,应用程序也可能在环境模式下运行。

对于表盘,您可以检查drawMode

https://github.com/android/wear-os-samples/blob/main/WatchFaceKotlin/app/src/main/java/com/example/android/wearable/alpha/AnalogWatchCanvasRenderer.kt#L221-L226

 override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
        val backgroundColor = if (renderParameters.drawMode == DrawMode.AMBIENT) {

对于

应用程序

AlwaysOnKotlin 示例演示如何支持您的应用在环境模式下绘图

Awake

Ambient

它使用 环境模式

I believe the watch controls this and it's usually a user setting to enable "Always on Display". Even in this mode, it's likely that the app also runs in ambient mode.

For Watchfaces, you can check the drawMode

https://github.com/android/wear-os-samples/blob/main/WatchFaceKotlin/app/src/main/java/com/example/android/wearable/alpha/AnalogWatchCanvasRenderer.kt#L221-L226

 override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
        val backgroundColor = if (renderParameters.drawMode == DrawMode.AMBIENT) {

When it

For Apps

This AlwaysOnKotlin sample demonstrates how to support your app drawing in Ambient mode

Awake

Ambient

It uses Ambient Mode

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文