Hi, is there a way to send a notification after a tot of time even if the application is closed? for example, to alert the user that something it is recharged thanks
Hello,
Yes using a service. You will initialize the notification from it. The point you will have to think about is the activity shown if the user clicks on the notification itself.
Sub btnCreateNotifications_Click
StartService(notifica)
End Sub
-In Notifica
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim timer1 As Timer
End Sub
Sub Service_Create
timer1.Initialize("timer1",7000)
End Sub
Sub Service_Start (StartingIntent As Intent)
timer1.Enabled=True
End Sub
Sub Service_Destroy
End Sub
Sub timer1_tick
Dim n As Notification
n.Initialize
n.SetInfo("Notification " & 1, "abcde", Me)
n.Icon = "icon"
n.Notify(1)
timer1.Enabled=False
End Sub