Hi
I am having some strange behaviour that some of my users are reporting. We have a Basic4Android App which has a built in timeout functionality. The idea being that if the app is not use for a certain length of time (2 minutes) the app times out back to the initial login screen.
The code to support this time out is as follows: -
Start by initializing a timer which ticks every 5 seconds. However it is set to disabled to start with.
With our system the users enter a pin to log in. When they enter their pin the timer 1 is set to enabled = true.
The timer 1 tick code is as follows: -
This means that every 5 seconds the timer adds one to the InActivityCount. That gives the user 2 minutes of possible activity.
Now, once the user has logged in there are various forms that interact with our database using an HTTP Post.
When the HTTP JobDone is called back this is where I set the InActivityCount variable to 0: -
So, the idea is that when the user loads a screen, which normally involves a HTTP call, the counter gets reset to 0 each time resetting the timer 1 event back to 2 minutes for user activity.
Some users are saying that the system is timing out whilst they are in a form. When I ask them how long they have been in a form they say only seconds!
Is it possible that the JobDone sub is clashing with the timer1 tick and that although it calls to set the InActivityCount to 0, in fact this is being overwritten by the timer1 tick? e.g. JobDone is called and tries to set InActivityCount = 0, but at same time timer1 tick is called and is already adding 1 to the current InActivityCount hence the counter is not reset?
I would say it is only happening 1 in 8 times of usage...
I am having some strange behaviour that some of my users are reporting. We have a Basic4Android App which has a built in timeout functionality. The idea being that if the app is not use for a certain length of time (2 minutes) the app times out back to the initial login screen.
The code to support this time out is as follows: -
B4X:
Sub Process_Globals
Dim InActivityCount As Long 'Declare global counter
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Timer1.Initialize("Timer1", 5000) ' 1000 = 1 second
Timer1.Enabled = False
End If
End Sub
Start by initializing a timer which ticks every 5 seconds. However it is set to disabled to start with.
With our system the users enter a pin to log in. When they enter their pin the timer 1 is set to enabled = true.
The timer 1 tick code is as follows: -
B4X:
Sub Timer1_Tick
InActivityCount = InActivityCount + 1
If InActivityCount > 24 Then
FinishButton_Click
End If
End Sub
This means that every 5 seconds the timer adds one to the InActivityCount. That gives the user 2 minutes of possible activity.
Now, once the user has logged in there are various forms that interact with our database using an HTTP Post.
B4X:
Public Sub LoadBehaviourScreen()
Dim HTTPCall As HttpJob
HTTPCall.Initialize("BehaviourList",Me)
HTTPCall.PostString("http://" & manager.GetString("CCIPAddress") & "/CareControl/CCResponse.aspx?TabletName=" & manager.GetString("CCTabletName") & "&Command=BehaviourList&Param1=&Param2=","")
End Sub
When the HTTP JobDone is called back this is where I set the InActivityCount variable to 0: -
B4X:
InActivityCount = 0
So, the idea is that when the user loads a screen, which normally involves a HTTP call, the counter gets reset to 0 each time resetting the timer 1 event back to 2 minutes for user activity.
Some users are saying that the system is timing out whilst they are in a form. When I ask them how long they have been in a form they say only seconds!
Is it possible that the JobDone sub is clashing with the timer1 tick and that although it calls to set the InActivityCount to 0, in fact this is being overwritten by the timer1 tick? e.g. JobDone is called and tries to set InActivityCount = 0, but at same time timer1 tick is called and is already adding 1 to the current InActivityCount hence the counter is not reset?
I would say it is only happening 1 in 8 times of usage...