Auto lock application

critalsoft

Member
Licensed User
Longtime User
I am working on one application which has a login screen. I want display the login screen again to the user when there is no activity by the user for say 10 min.

I shall be grateful, if some shares the code for this.

Thanks in advance!!!
 

critalsoft

Member
Licensed User
Longtime User
No, I would like to display my application's login screen. Something like auto lock application when there is no activity for some time.

Device gets automatically lock if not used for some time, so that is fine. But in my case if my application is not used for some time then it should show the login screen of my application. So that means, even you are working on some other application and you return to my application so it will show login screen if you came back to it after the lock period.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Add a service to your project.
In this service add a timer that ticks every minute. Each tick event increment a counter by one. If the counter reaches 10 then you know that you should show the login activity.
The counter should be a process global variable. So you can reset it from all activities (by setting its value to 0).

Do not call StartActivity from the service module. It is likely that your application is in the background at that time. Instead you should use a "flag" variable and check its value in Activity_Resume. If it is true then show the login page.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…