Android Question Reverse timer

rezaghasmi

Member


After execution, the code leaves the page


java.lang.IllegalStateException: Interval must be larger than 0.
at anywheresoftware.b4a.objects.Timer.setEnabled(Timer.java:79)
at b4a.example.rgeg._activity_create(rgeg.java:482)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.rgeg.afterFirstLayout(rgeg.java:104)
at b4a.example.rgeg.access$000(rgeg.java:17)
at b4a.example.rgeg$WaitForLayout.run(rgeg.java:82)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7561)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User

You haven't set your interval correctly here I would guess

B4X:
tmrCountdown.Initialize("tmr",1000)
 
Upvote 0

rezaghasmi

Member






B4X:
Sub Tmr_Tick
 If ( counter > 0) Then
      counter = counter - 1
     Dim sMin As Int = Floor(counter / 60)
     Dim sSec As Int = counter Mod 60
      Dim secPrefix As String =""
     Dim minPrefix As String =""
      If (sSec < 10) Then
      secPrefix = "0"
     End If
     If (sMin < 10 ) Then
       minPrefix = "0"
     End If
     txtCounter.Text = minPrefix & sMin &":"& secPrefix & sSec
     Else
     t.Enabled = False
 End If
 
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…