Hi
This is part of code:
This widget will be updated every 60 minutes and all views in widget will have some info. But if connection is off nothing will be d/l and all views will be empty for next 60 minutes. This will happen on device boot. My quwstion is how to go around this? I want my widget updated when conn is on and not after 60 minutes (the first time we boot device). So where to put which code which will after some time (seconds, minutes) start this again and if conn is on, d/l everything and update widget?
Thanks
This is part of code:
B4X:
...
Sub Service_Create
rv = ConfigureHomeWidget("test", "rv", 60, "test", 0)
End Sub
Sub Service_Start (StartingIntent As Intent)
If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub
Sub rv_RequestUpdate
If CheckConnection Then
DL_Something_1
DL_Something_2
...
rv.UpdateWidget
Else
Log("No Connection")
End If
End Sub
Sub DL_Something_1
Dim j1 as HttpJob
j1.Initialize("j1", Me)
j1.Download(some_uri)
End Sub
Sub JobDone(job As HttpJob)
If job.Success = True Then
Select job.JobName
Case "jq1"
parseXML...
SetData
End Select
Else
Log (job.ErrorMessage)
End If
job.Release
End Sub
Sub SetData
rv.SetText...
rv.SetImage...
rv.UpdateWidget
End Sub
Sub CheckConnection As Boolean
Dim ph As Phone
If (ph.GetDataState == "CONNECTED") Then
Log("connected TRUE")
Return True
End If
If (ph.GetSettings ("wifi_on") == 1) Then
Log("wifi ON")
Return True
End If
If (ph.GetDataState == "DISCONNECTED") Then
Log("disconnected TRUE")
Return False
End If
If (ph.GetDataState == "SUSPENDED") Then
Log("suspended TRUE")
Return False
End If
End Sub
...
This widget will be updated every 60 minutes and all views in widget will have some info. But if connection is off nothing will be d/l and all views will be empty for next 60 minutes. This will happen on device boot. My quwstion is how to go around this? I want my widget updated when conn is on and not after 60 minutes (the first time we boot device). So where to put which code which will after some time (seconds, minutes) start this again and if conn is on, d/l everything and update widget?
Thanks