Sub Service_Create
x=0
rv = ConfigureHomeWidget("wdgKatKal", "rv", 0, "Katolicki kalendar")
rv_RequestUpdate
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.Action = "android.appwidget.action.APPWIDGET_DELETED" Then Return
If rv.HandleWidgetEvents(StartingIntent) = False Then
rv_RequestUpdate
End If
If StartingIntent.Action <> "android.appwidget.action.APPWIDGET_DISABLED" Then
StartServiceAt("", TimeToNextMinute, False)
End If
End Sub
Sub rv_RequestUpdate
x=x+1
mnt = DateTime.GetMonth(DateTime.Now) 'find the current month
yr = DateTime.GetYear(DateTime.Now) 'find the current year
Database
DateTime.DateFormat = "d.M.yyyy" ' bila je tu točka na kraju
DateTime.TimeFormat = "HH:mm"
'saint of the day'
dbC = dbS.ExecQuery2 ("SELECT sveci,d,m,blagdan,pomicni_blag_"&yr&" FROM 'KatKalendar' WHERE m = ? AND d = ?", Array As String(mnt,DateTime.GetDayOfMonth(DateTime.Now)))
dbC.Position=0
...
dt = dbC.GetString("d")+x
datum = dt&"."&mnt&"."&yr&"."
dan = Days_hr(DateTime.GetDayOfWeek(DateTime.Now))
rv.SetText("lblSveci",sveci)
rv.SetText("lblDat",datum)
rv.SetText("lblDan",dan)
rv.SetText("lblFeast",feast)
rv.UpdateWidget
End Sub
Sub rv_Disabled
StopService("")
End Sub
Sub Service_Destroy
End Sub
Sub Database
Dim ruta As String
If File.ExternalWritable Then
ruta = File.DirDefaultExternal
Else
ruta = File.DirInternal
End If
'# Always copy new DB file
File.Copy(File.DirAssets, "kalendar.db", ruta, "kalendar.db")
dbS.Initialize(ruta, "kalendar.db", True)
End Sub
Sub TimeToNextMinute As Long
Dim ret As Long
ret=DateTime.TimeParse("10:28")
ret = ret + DateTime.TicksPerMinute
ret = ret - (ret Mod DateTime.TicksPerMinute)
Return ret
End Sub