Greetings,
I have this code to start a service module when the phone reboots but it doesn't start because my notification is not displayed on the app icon on the phone home screen. This was working in my original app before migrating it to B4APages. Is there any additional coding I need to add so the service module will start upon rebooting the phone? The good news is that Android doesn't kill this app and it runs in the background perfectly. I could tell the user to load the app on reboot but would rather it start by itself.
I have this code to start a service module when the phone reboots but it doesn't start because my notification is not displayed on the app icon on the phone home screen. This was working in my original app before migrating it to B4APages. Is there any additional coding I need to add so the service module will start upon rebooting the phone? The good news is that Android doesn't kill this app and it runs in the background perfectly. I could tell the user to load the app on reboot but would rather it start by itself.
Attribute to start the service module when the phone reboots.:
#Region Service Attributes
#StartAtBoot: True
#End Region
Service_Create and Service_Start:
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
Log("Starting service")
Service.StartForeground(nid, CreateNotification("Tapping this notification will open the app."))
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
InitializeWhatsNeeded
tmrForSchedules.Enabled = True
End Sub
Code for the notification.:
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_LOW)
notification.Icon = "icon"
notification.SetInfo("Now running in the background.", Body, Main)
Return notification
End Sub