Checking for password required

gadgetmonster

Active Member
Licensed User
Longtime User
Hi

I looking to implement password protection in my app but I am struggling to find the best place to do this.

Obviously I will check in the main activities Activity_Create sub when FirstTime is true but my problem is when the user does something like presses the home button, runs another app and then comes back to my app. Activity_Create is not called so I must look at Activity_Resume. Problem with Activity_Resume is that it is called everytime the user navigates back to the main screen.

So is there anyway I can detect that my app has lost focus so I could set a flag to get the user to enter the password again?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Create a public process global Long variable. Set this variable value to DateTime.Now in Activity_Pause of all your activities.

In Activity_Resume you should check whether more than x minutes have passed since the variable value. If yes then you should ask for a password.

Make sure to handle cases where the user presses on the Home button (or rotates the screen) when he is asked for the password.
 
Upvote 0
Top