Is there a simple code example for how to create timer-like service? I tried to use a timer to send SMSs at some interval but failed to keep it alive! here is what I did, I use android 6 phone and may upgrade to android 10.
B4X:
Sub SMSQueueTimer_Tick()
Sleep(0)
Dim SMS As clsSMS
SMS.Initialize
SMSQueueTimer.Enabled = False
lblLastSMSStatus.Text = "Listening..."
progsSMScontrolPanel.Visible = True
Wait For (CallSub3(SMS, "GetInfo","",True)) Complete (Isget As Boolean)
progsSMScontrolPanel.Visible = False
If Isget Then
Sleep(0)
lblsmsID.Text = ""
lblsmsFrom.Text = ""
lblsmsTo.Text = ""
lblCreatedDateTime.Text = ""
lblLastSMSStatus.Text = "Sending..."
'dont change method below
Dim smsTo As String = SMS.Info.smsTo
Dim smsBody As String = SMS.Info.Body
Dim smsID As String = SMS.Info.smsID
lblsmsID.Text = smsID
lblsmsFrom.Text = SMS.Info.SenderID
lblsmsTo.Text = smsTo
lblCreatedDateTime.Text = SMS.Info.CreatedDateTime
SendLargeSms(smsTo,smsBody,smsID)
'---------------------------------------
Else
ErrorsCounter = ErrorsCounter + 1
lblsmsErrors.Text = ErrorsCounter
lblLastSMSStatus.Text = "Server\Data Error"
End If
SMSQueueTimer.Enabled = True
End Sub