Hello Friends!
I have a Timer in the Starter Service, to watch for changes in a remote database, even if the app is minimized o in background the starter must check for the database changes. It works for a short period of time, then it crush. Heres is the image of the log error.
EDIT: Actually the title has to be: " Calling httpjobs in Starter Service"
And I check the database in the timertick event
Any tips?
Regards, Diego
I have a Timer in the Starter Service, to watch for changes in a remote database, even if the app is minimized o in background the starter must check for the database changes. It works for a short period of time, then it crush. Heres is the image of the log error.
EDIT: Actually the title has to be: " Calling httpjobs in Starter Service"
B4X:
Sub Service_Start (StartingIntent As Intent)
If gpsClient.GPSEnabled=True Then
' CallSub(Me,"StartGps")
timer2.Initialize("timer2",20000)
timer2.Enabled = True
' gpsClient.Start(0, 0)
' 'timer_gps.Initialize(timer_gps_tick, 35000)
' 'timer_gps.Enabled = True
' 'ProgressDialogShow("Waiting for GPS location")
End If
End Sub
And I check the database in the timertick event
B4X:
Dim ServerUrl As String
ServerUrl = "someurl.aspx?id=" & Main.idrepartidor
Log(ServerUrl)
Dim job As HttpJob
'Msgbox(ServerUrl,"")
job.Initialize("", Me)
job.PostString(ServerUrl,"")
Wait For (job) JobDone(j As HttpJob)
If job.Success Then
Dim parser As JSONParser
Dim response As String = job.GetString
'Msgbox(response,"")
parser.Initialize(response)
Dim rows As List
rows = parser.NextArray
If rows.Size > 0 Then
'Msgbox("trae filas","")
For i = 0 To rows.Size - 1
'SendMessage(str(Main.idrepartidor), "Nuevo Pedido", Main.nombre_cliente As String)
'Log("Rows #" & i)
Dim m As Map
m = rows.Get(i)
'Msgbox(Main.idrepartidor,"repartidor")
'Main.idrepartidor = m.Get("idrepartidor")
nombre_cliente = m.Get("nombre_solicitante")
Select m.Get("estado")
Case "P "
estado = "Pendiente"
If ya_notifique = 0 Then
Dim p As Phone
'Msgbox(p.SdkVersion,"")
If p.SdkVersion >= 21 Then
Dim nb As NotificationBuilder
nb.Initialize
nb.ContentTitle = "Nuevo Pedido"
nb.ContentText = "Nuevo Pedido de " & nombre_cliente
nb.AutoCancel = True
If Main.idrepartidor > 0 Then
nb.setActivity(interfaz_inicio)
Else
nb.setActivity(Main)
End If
nb.SmallIcon = "ducati"
ya_notifique = 1
Main.notifico = 1
'nb.Notify(1)
If p.SdkVersion >= 26 Then
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim manager As JavaObject
manager.InitializeStatic("android.app.NotificationManager")
Dim Channel As JavaObject
Dim importance As String
importance = "IMPORTANCE_HIGH"
Dim ChannelVisibleName As String = Application.LabelName
Channel.InitializeNewInstance("android.app.NotificationChannel", _
Array("MyChannelId1", ChannelVisibleName,manager.GetField(importance)))
manager = ctxt.RunMethod("getSystemService", Array("notification"))
manager.RunMethod("createNotificationChannel", Array(Channel))
Dim jo As JavaObject = nb
jo.RunMethod("setChannelId", Array("MyChannelId1"))
ya_notifique = 1
nb.Notify(1)
Return
Else
nb.Notify(1)
End If
Else
Dim n As Notification
n.Initialize
n.AutoCancel = True
n.Icon = "ducati"
If Main.idrepartidor > 0 Then
n.SetInfo("EnviaPy","Nuevo pedido de " & nombre_cliente, interfaz_inicio)
Else
n.SetInfo("EnviaPy","Nuevo pedido de " & nombre_cliente, Main)
End If
ya_notifique = 1
Main.notifico = 1
n.Notify(1)
End If
End If
'End If
Case "R "
Case "T "
End Select
Next
End If
End If
End If
End Sub
Any tips?
Regards, Diego
Attachments
Last edited: