Sub Service_Create
rv = ConfigureHomeWidget("widget2x2", "rv", 1440, "Testing")
End Sub
Sub Service_Start (StartingIntent As Intent)
' If a widget is removed from homescreen we don't need to do anything
If StartingIntent.Action = "android.appwidget.action.APPWIDGET_DELETED" Then Return
' We have to be sure that we do not start the service
' again if all widgets are removed from homescreen
If StartingIntent.Action <> "android.appwidget.action.APPWIDGET_DISABLED" Then
Dim schedule As Long
Dim now As Long = DateTime.now
schedule = DateUtils.SetDateAndTime(DateTime.GetYear(now), DateTime.GetMonth(now), DateTime.GetDayOfMonth(now),0,5,0)
If schedule < now Then
'skip to tomorrow
Dim p As Period
p.Days = 1
schedule = DateUtils.AddPeriod(schedule, p)
End If
StartServiceAt("",schedule,True)
End If
' Handle the widget events
If rv.HandleWidgetEvents(StartingIntent) = False Then
' If the action is not handled by HandleWidgetEvents() then we
' probably were called by StartService() or StartServiceAt().
' So just update the widget.
rv_RequestUpdate
End If
End Sub