Hi all.
I have a small app (this is just an example) that does nothing but runs a timer.
It also has 2 activities and my code in Starter runs a timer that checks if both of theses activities are paused.
If so - let's wait for 10 seconds a show a message in a log Log("Log Out")
The idea is that if user has left for a while I want him to login back.
The problem is that the app finishes without any message and it can stop while counter is about 8 or 9. Never riches 10.
Here is a code
Please see this attached project.
Thanks.
I have a small app (this is just an example) that does nothing but runs a timer.
It also has 2 activities and my code in Starter runs a timer that checks if both of theses activities are paused.
If so - let's wait for 10 seconds a show a message in a log Log("Log Out")
The idea is that if user has left for a while I want him to login back.
The problem is that the app finishes without any message and it can stop while counter is about 8 or 9. Never riches 10.
Here is a code
Starter code:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private Timer As Timer
Private Counter As Int
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Timer.Initialize("Timer1",60000)
End Sub
Sub Service_Start (StartingIntent As Intent)
Try
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
Timer.Enabled=True
Catch
Log("Service_Start " & LastException)
End Try
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
Try
Log("Service_TaskRemoved")
Catch
Log("Service_TaskRemoved " & LastException)
End Try
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Log(StackTrace & " " & Error.Message)
Return True
End Sub
Sub Service_Destroy
Try
Log("Service_Destroy")
Catch
Log("Service_Destroy " & LastException)
End Try
End Sub
private Sub RunCounter
Try
Dim IsP1 As Boolean
Dim IsP2 As Boolean
IsP1=IsPaused(Main)
IsP2=IsPaused(screen2)
Log("IsP1=" & IsP1 & " IsP2=" & IsP2)
If IsP1 And IsP2 Then
Counter = Counter + 1
Log("Counter=" & Counter)
If Counter = 10 Then
Log("Logged Out")
End If
Else
Counter = 0
End If
Catch
Log("RunCounter " & LastException)
End Try
End Sub
Sub timer1_tick
Try
RunCounter
Catch
Log("timer1_tick " & LastException)
End Try
End Sub
Please see this attached project.
Thanks.