Keep display active in Android WebView apps ๐Ÿ”›

Black Lady Using Cellphone With Weight-Loss App Cooking In Kitchen

WebViews are the most common way to display content on Android apps. But they have a drawback: they will turn off the screen after a time limit.

This can be very frustrating for users if they read something interesting, like engaging in a step-by-step cooking app. So in this article, we are going to share with you how to keep your Android WebView app display always on.

This is an easy way for developers to ensure that their users never lose their place when using their app: This problem can be solved by preventing sleep in WebView for Android apps, simply because the screen should not turn off automatically in mode of inactivity. It should stay on all-time until we explicitly ask for turning off the screen manually through code or other action like clicking on an external window or navigating out of our current activity window.

This is how it works efficiently:

  1. Getย WebViewGold for Android
  2. Navigate to Config.java file
  3. Turn theย PREVENT_SLEEPย boolean variable to true.
  4. Done! ๐Ÿ™‚