Android Question How to check if a service is scheduled ?

Andre Souza

Member
Licensed User
My app has a service that starts every time the app is opened for the Main every hour .

Then it issues a notification . The service returns only if the user clicks the notification and so on.

I wanted to know what command I can add on Main to see if the service is already scheduled, because every time you open the app , it always adds an extra hour .

I've tried isPaused and not working .


::: MAIN :::
B4X:
Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("ly_Home")
    StartServiceAt(SV_Notificar,DateTime.Now +3600 * 1000, True)
End Sub


:::MAIN:::
Example Similar
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("ly_Home")
if ServiceRunning() then   
StartServiceAt(SV_Notificar,DateTime.Now +3600 * 1000, True)
End If
End Sub

An alternative that I thought was every time you start , compare time of the last notification clicked with the opening of the app to see if already spent an hour . Is it correct ?
 
Top