How to prevent automatic screen lock on android by code?

Sanjay S Gangwar
Jan 8, 2021

--

Just call this method and no need to get permission in the manifest file.

private void keepScreenOn() {   
getWindow().
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

Hope it helps you. 😁😁

--

--

Sanjay S Gangwar
Sanjay S Gangwar

Written by Sanjay S Gangwar

0 Followers

Just an average android developer.

No responses yet