#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private AcNot As Boolean
End Sub
Sub Service_Create
Service.AutomaticForegroundMode= Service.AUTOMATIC_FOREGROUND_WHEN_NEEDED
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, False)
If StartingIntent.HasExtra("android.intent.extra.ALARM_COUNT") Then
AcNot = False
Dim Co As Cursor
Dim NOTID As Int
Dim FEEDID As Long
Dim QSID As Int
Dim FeedNot As Int
Log("service started")
Dim Rc As Map
Co = Starter.SQLF.ExecQuery("Select * from Setting")
If Co.RowCount > 0 Then
Co.Position = 0
NOTID = Co.GetInt("NOTID")
FEEDID = Co.GetLong("FEEDID")
QSID = Co.GetInt("QSID")
FeedNot = Co.GetInt("FEEDNOT")
End If
Co.Close
Dim R As List
j.Initialize("", Me)
j.Download2("https://hypogene-fault.000webhostapp.com/indexl.php",Array As String ("action", "getlastqsid"))
j.GetRequest.Timeout =60000
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
parser.Initialize(j.GetString )
R = parser.NextArray
Dim ItemM As Map
Dim Catt As String
If R.Size > 0 Then
ItemM = R.Get(0)
If QSID <> ItemM.Get("ID") Then
Dim n As NB6
n.Initialize("997", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(LoadBitmap(File.DirAssets,"applogo.png"))
n.Build("Teach Islam - Ask Expert", ItemM.Get("Q"), "tag1", Ask).Notify(997) 'It will be Main (or any other activity) instead of Me if called from a service.
Dim C As Cursor
c = Starter.SQLF.ExecQuery("Select * from setting")
If C.RowCount > 0 Then
Dim Qry As String
Qry="UPDATE Setting SET QSID = " & ItemM.Get("ID")
Starter.SQLF.BeginTransaction
Starter.SQLF.ExecNonQuery(Qry)
Starter.SQLF.TransactionSuccessful
Starter.SQLF.EndTransaction
Log(ItemM.Get("ID"))
End If
End If
End If
End If
Log("service end")
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End If
End Sub
Sub Service_Destroy
End Sub