Sub Process_Globals
Private rv As RemoteViews
Private imageFiles() As String = Array As String("player_button_next.png", "player_button_pause.png", _
"player_button_play.png", "player_button_stop.png")
Private currentImage As Int
Private hgg As PhoneEvents
Private BatLevel As Int
Private Timer1 As Timer
End Sub
'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
Timer1.Initialize("Timer1", 1000)
If FirstTime Then
Log("Enter the first time and activate the Receiver")
rv = ConfigureHomeWidget("L1", "rv", 60, "Hello Widget")
hgg.Initialize("hgg")
Sleep(200)
Button1_Click
End If
Timer1.Enabled = True
rv.HandleWidgetEvents(StartingIntent)
Sleep(500)
rv.UpdateWidget
Timer1.Enabled = True
End Sub
Private Sub rv_RequestUpdate
Log("rv_RequestUpdate: Message received by Receiver")
ImageView1_Click
SetTime
rv.UpdateWidget
End Sub
Private Sub SetTime
Log("SetTime: Update time")
rv.SetText("Label1", DateTime.Time(DateTime.Now))
End Sub
Private Sub ImageView1_Click
Log("ImageView1_Click: Update widget contents")
currentImage = (currentImage + 1) Mod imageFiles.Length
rv.SetImage("ImageView1", LoadBitmap(File.DirAssets, imageFiles(currentImage)))
'rv.SetProgress("ProgressBar1", 100 * (currentImage + 1) / imageFiles.Length)
rv.SetProgress("ProgressBar1", BatLevel)
rv.SetText("Label2", BatLevel & "%")
SetTime
rv.UpdateWidget
End Sub
Private Sub Button1_Click
Log("WidgetReceiver --> Button1_Click: Opens Activity Main")
StartActivity(Main)
End Sub
Sub Timer1_Tick
' event Timer1
Log("Timer1: event")
Timer1.Enabled = False
'ImageView1_Click
rv.SetProgress("ProgressBar1", BatLevel)
rv.SetText("Label2", BatLevel & "%")
SetTime
rv.UpdateWidget
Timer1.Enabled = True
End Sub
Public Sub hgg_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
' Get Battery level
BatLevel = Level
End Sub