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

Heute, 07:28 in der App-Version 33
Samsung Galaxy J5 Prime (on5xelte), 2048MB RAM, Android 6.0
Bericht 1 von 70
java.lang.RuntimeException
:
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:223)
at anywheresoftware.b4a.objects.Timer$TickTack.run (Timer.java:105)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:7406)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.RuntimeException:
at anywheresoftware.b4a.keywords.Common.CallSub4 (Common.java:1064)
at anywheresoftware.b4a.keywords.Common.CallSubNew2 (Common.java:993)
at fg.speedpilot_lite.starter._gpstimer_tick (starter.java:348)
at java.lang.reflect.Method.invoke (Native Method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:186)
 
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

Top