I needed to create a password entry screen that could be called from any activity after a timeout. I did this by making a class called clsLockScreen. This class has a public method called LockScreen which goes something like this:
B4X:
Public Sub LockScreen
DrawScreen
Do while lbEnteredPassword.text <> setPassword
DoEvents
Loop
End Sub
So when called from an activity, the DrawScreen function will draw a panel over the entire screen and add a label and 10 numeric buttons. When the buttons are pressed, the number is added to lbEnteredPassword.text The loop will keep looping until such a time as the lbEnteredPassword label matches the set password.
Whilst this seems to work, I'm pretty sure this is not the right way to do it. Can anyone suggest a better method please?
You shouldn't use a loop in this manner, you can consume the touch events from the panel by adding either empty Click and LongClick or Touch subs so nothing else can be processed and test and manage the password entry in the button up event.