Android Question StartServiceAt problem

Almog

Active Member
Licensed User
Hello,

I now trie to use StartServiceAt by Erel's example (https://www.b4x.com/android/forum/threads/startserviceat-headaches.33646/#post-196829)

B4X:
Sub Service_Start (StartingIntent As Intent)
    StartServiceAt(Me, NextTimeInstance(17, 27) ,True)
    StartActivity(Main)

End Sub

Sub NextTimeInstance (Hours As Int, Minutes As Int) As Long
    Dim today As Long = DateTime.Now
    today = DateUtils.SetDateAndTime(DateTime.GetYear(today), DateTime.GetMonth(today), _
     DateTime.GetDayOfMonth(today), Hours, Minutes, 0)
    If today < DateTime.Now Then
        Dim p As Period
        p.Days = 1
        Dim tomorrow As Long = DateUtils.AddPeriod(today, p)
        Return tomorrow
    Else
        Return today
    End If
End Sub
It worked(thank you), but when the app launched, a push notification is showed up, and it's unremovable, even if I close the app I can't hide the push notification from my notifications from my phone...

Does anybody know how can I fix this problem? (and how can I change the label of this notification - right now the label is "b4a example")

Thanks in advance...
 

MarkusR

Well-Known Member
Licensed User
i guess the notification comes because
DuringSleep True

if a foreground service is running non stop the notification is an indicator for end user.
the android activity windows are running only if u see it.
 
Top