Sub Process_Globals
Dim Notifikation As Notification
Dim rv As RemoteViews
Dim imgFiles() As String
imgFiles = Array As String("bulboff.png", "bulbon.png")
Dim Status As Int
Dim Ti As Timer
Ti.Initialize("UpdateTimer", 5000)
Ti.Enabled = False
End Sub
Sub Service_Create
' Calculating the size of widgets based on the desired column
' (number of cells * 74) - 2) (1 * 74) - 2 = 72db
rv = ConfigureHomeWidget("Widget", "rv", 30, "ScreenOn Widget")
Notifikation.Initialize
Notifikation.Sound = False
Notifikation.Vibrate = False
End Sub
Sub Service_Start (StartingIntent As Intent)
If rv.HandleWidgetEvents(StartingIntent) Then
Return
End If
End Sub
Sub rv_Disabled
StopService("")
End Sub
Sub imgWidget_Click
Dim pws As PhoneWakeState
Status = (Status + 1) Mod imgFiles.Length
rv.SetImage("imgWidget", LoadBitmap(File.DirAssets, imgFiles(Status)))
If Status = 1 Then
pws.KeepAlive(True) ' display stays on
Ti.Enabled = True
Else
pws.ReleaseKeepAlive ' display stays off
Ti.Enabled = False
End If
rv.UpdateWidget ' Update widget
End Sub
Sub UpdateTimer_Tick
Try
Service.StartForeground(1, Notifikation)
Catch
imgWidget_Click
End try
End Sub