FLAG_KEEP_SCREEN_ON 仍然导致屏幕变暗
FLAG_KEEP_SCREEN_ON still results in dim screen
在我的 Android activity 中,我设置了 FLAG_KEEP_SCREEN_ON
标志,如下所示:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
...
}
尽管如此,我的屏幕在 activity 几分钟后变暗了。
请问有没有更好的办法保证屏幕不暗?问候。
这不是解决方案,但 Android 文档说 FLAG_KEEP_SCREEN_ON
as long as this window is visible to the user, keep the device's
screen turned on and bright.
我还制作了一个示例应用程序,只需在 activity 中添加这一行,它就可以运行。我让应用程序保持原样超过 5 分钟,并且根本没有变暗。我猜你的代码还有其他问题。当亮度降低时,您是否处于完全相同的 activity?
您可以尝试的另一件事是使用 WakeLocks (NOT RECOMMENDED). But note that its not a good practice to use it (at least just for your requirement for screen brightness purposes). You can find the code for the same here. You should also take a look at this blog,它讨论了打开屏幕的 3 种方法。
在我的 Android activity 中,我设置了 FLAG_KEEP_SCREEN_ON
标志,如下所示:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
...
}
尽管如此,我的屏幕在 activity 几分钟后变暗了。
请问有没有更好的办法保证屏幕不暗?问候。
这不是解决方案,但 Android 文档说 FLAG_KEEP_SCREEN_ON
as long as this window is visible to the user, keep the device's screen turned on and bright.
我还制作了一个示例应用程序,只需在 activity 中添加这一行,它就可以运行。我让应用程序保持原样超过 5 分钟,并且根本没有变暗。我猜你的代码还有其他问题。当亮度降低时,您是否处于完全相同的 activity?
您可以尝试的另一件事是使用 WakeLocks (NOT RECOMMENDED). But note that its not a good practice to use it (at least just for your requirement for screen brightness purposes). You can find the code for the same here. You should also take a look at this blog,它讨论了打开屏幕的 3 种方法。