Search code examples
androidandroid-camerawakelockandroid-wake-lock

How the camera hold the wake-lock in Android 4.2?


Normally , we use the wake-lock mechanism to keep the app bright . But when I study the Android Camera , I found there isn't any information about the wake-lock, including acquire the wake-lock and release the wake-lock.

When I set the sleep setting which in the display setting to 15 seconds , that is to say, after 15 seconds the screen will go to sleep if there isn't any operations. But when I launch the Camera and do nothing , I found the screen is bright after the 15 seconds had passed.

So how the camera hold the wake-lock? How the camera keep the screen bright longer than the sleep setting in display setting in Android 4.2? I am confused about it.


Solution

  • The foreground activity can keep the screen on, while that activity remains in the foreground. The easiest way to do this is to use android:keepScreenOn="true" or setKeepScreenOn(true) on any widget or container in your activity's layout.