#Region Service Attributes
#StartAtBoot: True
#ExcludeFromLibrary: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hitung As Int
Dim shouldScheduleNextTask As Boolean
shouldScheduleNextTask = True 'by default we are scheduling the next update
Dim i As Int
Private LOGIN = "login"
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
End Sub
Sub Service_Start (StartingIntent As Intent)
If shouldScheduleNextTask Then
StartServiceAt("", DateTime.Now + 5 * DateTime.TicksPerMinute, True)
End If
ExecuteRemoteQuery("SELECT username, area, kegiatan, menu FROM notification where waktu >= (now() - INTERVAL 5 MINUTE)" , LOGIN)
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Sub ExecuteRemoteQuery(query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.astacomputer.com/countries.php", query)
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res, menu As String
Dim username,area,kegiatan As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case LOGIN
Dim USERINFO As List
USERINFO = parser.NextArray 'returns a list with maps
For i = 0 To USERINFO.Size - 1
Dim m As Map
m = USERINFO.Get(i)
username = m.Get("username")
area = m.Get("area")
kegiatan = m.Get("kegiatan")
menu = m.Get("menu")
Dim n As Notification
n.Initialize
If Main.USERNAME = "" Then
n.SetInfo(kegiatan, username &" - "& area, Main)
Else
If menu = "main" Then n.SetInfo(kegiatan, username &" - "& area, Main)
If menu = "page1" Then n.SetInfo(kegiatan, username &" - "& area, page1)
If menu = "menu1" Then n.SetInfo(kegiatan, username &" - "& area, menu1)
If menu = "menu2" Then n.SetInfo(kegiatan, username &" - "& area, menu2)
If menu = "menu3" Then n.SetInfo(kegiatan, username &" - "& area, menu3)
If menu = "menu4" Then n.SetInfo(kegiatan, username &" - "& area, menu4)
If menu = "menu5" Then n.SetInfo(kegiatan, username &" - "& area, menu5)
If menu = "menu6" Then n.SetInfo(kegiatan, username &" - "& area, menu6)
If menu = "menu6" Then n.SetInfo(kegiatan, username &" - "& area, menu6)
End If
n.Icon = "icon"
n.AutoCancel = True
n.Notify(i)
Next
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
ProgressDialogHide
End Sub