Android Question General question about timer

D

Deleted member 103

Guest
Hi,
A timer in an activity should always be terminated in Activity_Pause.

Question: When should a timer started in the Starter-service be terminated?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I guess that you mean disabled, not terminated.

Timers in activities should be process global objects and should be disabled in Activity_Pause.

When should a timer started in the Starter-service be terminated?
If you want it to run all the time then you don't need to disable it at all.
 
Upvote 0
D

Deleted member 103

Guest
If you want it to run all the time then you don't need to disable it at all.
I'm trying to find why I have a lot of crash in my app.
In my starter service I have the following:
B4X:
Sub GpsTimer1_Tick
    Dim time As Long = DateTime.Now

    If Not(IsPaused(Main)) Then
        CallSub2(Main, "ShowClocktime", DateTime.time(time))
    End If
   
    If IsCronoRunning Then
                               
        If Not(IsPaused(Main)) Then
            CallSub(Main, "ShowCronoRunning")
        End If
    End If
   
    CallSub2(Main, "ShowAutoStart", time)
End Sub

 
Upvote 0
D

Deleted member 103

Guest
This will tell you where it fails. In ShowClockTime or ShowAutoStart.
but I do not see what was causing the problem, here is my code:
B4X:
Public Sub ShowClocktime(Clocktime As String)
    lblClock.Text = Clocktime
End Sub

Public Sub ShowAutoStart(time As Long)
    If pnlAutoStart.Visible Then
        Dim h,m,S As Int
        h = DateTime.GetHour(time)
        m = DateTime.GetMinute(time)
        S = DateTime.GetSecond(time)
        time = (S * DateTime.TicksPerSecond) + (m * DateTime.TicksPerMinute) + (h * DateTime.TicksPerHour)
        lblTime.Text = mBBL.getConvertTickTo_HHmmss(lblTime.Tag - time)

        If Starter.manager.GetBoolean("cbxSpeedBeep") Then
            Dim t As Int = (lblTime.Tag - time) / DateTime.TicksPerSecond
            If t <= 10 And Starter.Autostarttime <> t Then
                Starter.Autostarttime = t
                If t > 0 Then
                    CallSub(Starter, "Start_beep200")
                Else If t = 0 Then
                    CallSub(Starter, "Start_beep500")
                End If
            End If
        End If   

        If (lblTime.Tag - time) <= 0 Then
            btnCancelAutostart_Click
        End If
    End If
End Sub
 
Upvote 0

Similar Threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…