Try this answer:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow
is a method defined for activities, and won’t require you to find a View
first.
More Related Contents:
- How to support different screen size in android
- Application Skeleton to support multiple screens
- Android splash screen image sizes to fit all devices
- android: broadcast receiver for screen on and screen off
- Force “portrait” orientation mode
- How to get screen dimensions as pixels in Android
- Is there a way to determine android physical screen height in cm or inches?
- Changing screen brightness programmatically (as with the power widget)
- How to determine device screen size category (small, normal, large, xlarge) using code?
- Screen orientation lock
- Detecting when screen is locked
- Android Battery in SDK
- Prevent screen rotation on Android
- How to start Power Manager of all android manufactures to enable background and push notification?
- How to check an Android device is HDPI screen or MDPI screen?
- How to display Activity when the screen is locked?
- Developing a custom lock screen [duplicate]
- Turning on screen programmatically
- Android accelerometer not working when screen is turned off
- Android: how to convert whole ImageView to Bitmap?
- Android – How to display a dialog over a native screen?
- Detect 7 inch and 10 inch tablet programmatically
- How to get information about android battery usage by application
- How to avoid restarting activity when orientation changes on Android
- onDestroy gets called each time the screen goes on
- android: turn off screen when close to face
- Creating multi-screen support app android
- Turn off screen programmatically when face is close the screen on Android
- android unlock screen intent?
- Splash screen while loading a url in a webview in android app