/* Window flag: as long as this window is visible to the user, keep the device’s screen turned on and bright. /
public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
WindowManager提供了FLAG_KEEP_SCREEN_ON,让开发者更方便实现屏幕常亮。
用法也很简单:
让屏幕常亮
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
释放屏幕
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
本文介绍了如何使用WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON标志实现Android应用中屏幕常亮的功能。通过简单的两行代码即可轻松控制设备屏幕的亮灭状态。
3717

被折叠的 条评论
为什么被折叠?



