Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent Android from auto locking while activity (application) is in focus?

I'm new to android development. How can I prevent Android from locking while my application is in focus? When my application is out of focus I want to ensure than the android os will have its default behavior.

like image 896
Hikmat Khan Avatar asked Jan 19 '23 10:01

Hikmat Khan


1 Answers

use

WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON

you can do this using

Activity.getWindow().addFlags().

like image 182
Sujit Avatar answered Jan 29 '23 21:01

Sujit