Android Question Service not working

cbanks

Active Member
Licensed User
Longtime User
Why doesn't the code in my service happen when the app is not open? I start the service when the app runs the first time.

B4X:
#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.
    Dim ReminderTimer As Timer
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    ReminderTimer.Initialize("ReminderTimer", 60000) '60 seconds
    ReminderTimer.Enabled = True
End Sub

Sub Service_Destroy

End Sub

Sub ReminderTimer_Tick
    Dim now = DateTime.Time(DateTime.Now) As String
    now = now.SubString2(0, 5)
   
    Dim r As Notification
    r.Initialize
    r.Sound = True
    r.Vibrate = True
    r.Icon = "icon"
    r.SetInfo("Daily Reading Reminder", "It is time to read the scriptures.", "Main")
    r.Notify(1)
   
    If File.Exists(File.DirInternal, "DailyReminder.txt") Then
        Dim TextReader1 As TextReader
        TextReader1.Initialize(File.OpenInput(File.DirInternal, "DailyReminder.txt"))
        Dim DailyReminderTime As String
        DailyReminderTime = TextReader1.ReadLine
        TextReader1.Close
       
        ToastMessageShow(now & CRLF & CRLF & DailyReminderTime, True)
       
        If DailyReminderTime = now Then
            Dim r As Notification
            r.Initialize
            r.Sound = True
            r.Vibrate = True
            r.Icon = "icon"
            r.SetInfo("Daily Reading Reminder", "It is time to read the scriptures.", "Main")
            r.Notify(1)
        End If
    End If
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…