英文:
Android wear: keeping display on
问题
在我的表盘上,有时我需要等待相对较长的时间来获取数据。在这段等待时间内,我认为保持显示屏开启会很好。不幸的是,我没有通过与我在手机上实现相同的方式(使用PowerManager.WakeLock)使其正常运行。
有人能否为我提供一个正确的方法来实现这一点?
非常感谢,
Luca
英文:
On my watchface I need sometimes do wait a relative long time for data. During this wait cycle I think, it would be nice to keep the display on.<br/>
Unfortunately I didn't got it running with the same way I got it on my mobile phone (using PowerManager.WakeLock).
Can someone suggest me a right way to do that?
Thanks a lot<br/>
Luca
答案1
得分: 1
好的,以下是您要翻译的内容:
我使用 PowerManager 得到了它... <br/>
我只是忘记在我的 AndroidManifest.xml 中添加:
<uses-permission android:name="android.permission.WAKE_LOCK" />
很抱歉
谢谢<br/>
Luca
英文:
Well, I got it with PowerManager...<br/>
I just forgot to add:
<uses-permission android:name="android.permission.WAKE_LOCK" />
to my AndroidManifest.xml...
Thanks<br/>
Luca
答案2
得分: 0
使用窗口标志:只要此窗口对用户可见,就保持设备屏幕保持开启和亮起。
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
如果不起作用,请查看此链接 在可穿戴设备上保持应用可见性,它可能会对您有所帮助。
英文:
Use Window flag: as long as this window is visible to the user, keep the device's screen turned on and bright.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
If it doesn't work check this link Keep your app visible on Wear It might help you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论