Wakelock和FLAG

编程入门 行业动态 更新时间:2024-10-10 15:22:07
本文介绍了Wakelock和FLAG_KEEP_SCREEN_ON之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

保持清醒的屏幕可以实现通过使用wakelock通过

Keeping the screen awake can be accomplished by using a wakelock by

mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());

或者通过将FLAG_KEEP_SCREEN_ON到窗口,

Or by adding the FLAG_KEEP_SCREEN_ON to the window,

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

这是在两者之间并在性能和电池寿命方面,这是推荐的技术差异?

What is the technical difference between the two and in terms of performance and battery life which is recommended?

推荐答案

一个wakelock给你的方式更多的控制(像唤醒手机下载的东西,而不转动屏幕关闭),并要求您的应用程序保持wakelock权限。

A wakelock gives you way more control (Like waking the phone to download something without turning the screen off) and requires your application to hold the wakelock permission.

因此​​ FLAG_KEEP_SCREEN_ON 建议如果你想要的是保持在屏幕上,而你的窗口是可见的。

Therefore FLAG_KEEP_SCREEN_ON is recommended if all you want is to keep the screen on while your window is visible.

更多推荐

Wakelock和FLAG

本文发布于:2023-11-27 09:45:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Wakelock   FLAG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!