Sub Service_Create
Log("Service Started")
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt("", TomorrowAt10, False)
BuildNotification
So the service start and I build a notification at TomorrowAt10.
But, if I close the app and re-open it, I have a new notification all times.
How can I prevent it?
I read with "IsPaused" and I tried to use it, but I can't find a valid solution.
Please Help
You have a notification every time the app starts because when the code starts the service, the service is first scheduled at tomorroeAt10 and then you call build notification.
StartServiceAt(Me, TomorrowAt10, False)
StartingIntent.Action will be "android.intent.action.BOOT_COMPLETED"
[CODE]
at the beginning of the service in a try?
'Activity
If FirstTime Then 'whn your activity starts, you call the service
StartService("Svc")
End If
Sub Service_Start (StartingIntent As Intent) 'Here the service starts
StartServiceAt("", TomorrowAt10, False) 'The next re-start is schedulet for TomorrowAt10
BuildNotification 'The notification pops up
As you can see, when you activity is created, you start the service- The service schedules itself for TomorrowAt10 and THEN you buildNotification. The buildNotification is ALWAYS executed when your app starts.
You should use StartServiceAt in your Activity_create.
If you use StartServiceAt in the firsttime AND the service starts immediately (you get the notification) it simply means that the tomorrowAt10 value is somewhere in the past (not tomorrow) and for this reason the service starts immediately instead of wait for TomorrowAt10.
Where do you calculate TomorrowAt10?
I mean, are you sure the value is always what you're expecting? Try and log that value every time you use it.