How to lock buttons / Android phone from code (screen lock)?

Possible duplicate:
Lock Android device programmatically

I made a simple Android app with a PIN / screen lock. The user must write a password to lock the phone, and then repeat it to unlock the phone. The problem is that the user can still press home (etc.) to exit the application without writing the code. How can I prevent this?

+5
java android locking
Oct 17 2018-10-17
source share
3 answers

You can lock the back button by overwriting dispatchKeyEvent() in your Activity class and return true if event.getKeyCode() is equal to KeyEvent.KEYCODE_BACK . But you cannot block the Home button from going to the home page.

I heard of some kind of cheating where you register your application as the recipient of the intent android.intent.category.HOME . This will cause the Android OS to load your activity if the user clicks the home button. If you can make this work, you can load the "actual" home screen if the user has entered the correct password. However, this approach is likely to behave differently on different devices and versions of Android, and it probably would not do anything to stop the Hold-Home task list.

The bottom line is that the Android OS was designed to prevent everything that you are trying to do: the application should not be able to control the phone and not start other applications (especially the phone).

+4
Oct 17 '10 at 18:18
source share

I understand that you cannot lock the home key, as it is a security feature that allows the user to always exit the application. However, clicking on the house will not close the operation.

0
Oct. 17 '10 at 18:18
source share

the guys who created the free "Toddler lock", apk somehow succeeded - download and see for yourself :)

when you launch it, it asks for permission to run as a home application, and you need to check the "use by default" checkbox. To exit the application, you need to click on all 4 corners of the screen. All but one of the buttons are locked. So there is a way to do it!

he explains to users how it works here: http://www.toddlerlock.com/3.html

0
Oct 17 2018-10-17
source share



All Articles