Dim screen while user inactive

前端 未结 3 1950
长情又很酷
长情又很酷 2021-01-11 18:46

I have an app which is used for lets say 4 hours, but only every 5 minutes a user needs to make an input or read the screen. Putting the phone to sleep and locking the scre

3条回答
  •  天命终不由人
    2021-01-11 19:47

    Even a dim screen consumes a significant amount of battery over a time like 4 hours. You really don't want to keep the screen on like that. I think you would be better off using FLAG_SHOW_WHEN_LOCKED, allowing the screen to turn off, but for the user to immediately go in to your app when turning it back on without having to first go through the lock screen.

    If you really need to keep the screen dim, you can use a SCREEN_DIM_WAKE_LOCK. If you want more control, you could also try directly setting the screen brightness with WindowManager.LayoutParams.screenBrightness.

提交回复
热议问题