How to protect my home key if my application is active? (Screensaver, Lockscreen)

If I want to write a screensaver or lockscreen. Is there a way to prevent the home key from returning to the launcher?

+3
source share
3 answers

Check out this link here. I already answered! Android - Can I turn off the home button press

and

How to disable the home key

+1
source

Simple: when entering activity, call

getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);

and when you exit this operation, call

getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION);
+1
source

- Android no-no.

The only screensaver in Android should be a screen. Why does someone want to run away from their battery instead of just pressing a single button to turn off the screen and do the same to turn it on again? It just doesn't make sense on a device with a very limited power source to run the screen saver.

I'm not quite sure, but from what I read on the Internet, custom lock screens can only be executed in custom firmware or in root applications.

0
source

Source: https://habr.com/ru/post/1763022/


All Articles