In my app there is a long loading process, and if the devices puts on the screen lock, my process stops for some reason.
How can i prevent the device from automatic screen lock?
In my app there is a long loading process, and if the devices puts on the screen lock, my process stops for some reason.
How can i prevent the device from automatic screen lock?
The following line allows your phone to be ON when the app is in foreground
The following instructions allow us to disable the lock screen when lock button is pressed. KeyguardLock class was deprecated in API level 13
And in your manifest:
Another way to keep the screen lock on without having to request the permission in the manifiest is:
Are you doing your long loading process in the UI thread? Something doesn't seem right - if the process is so long that the screen lock timesout and your process ends, perhaps it needs to go in a background service.
in androidmanifest:
OR
Follow this link
XML Way:
Just use
keepScreenOn
attribute in your parent layout:programmatically:
You can set it programmatically by adding flag:
one interesting option that wasn't mentioned yet is the
method. This can actually be used dynamically at any point during the runtime of the app, e.g. for setting the screen mode depending on the app state
Go with the key guard code its working perfectly,
Just Paste the code in onCreate Method in your mainactivity file And Permission in android manifest file