Greetings,
We have a B4XPages app that includes a service module that starts with #StartAtBoot: true. Because B4XPages doesn't start upon a phone reboot, we would like to start B4XPages from that module when the user reboots their phone.
Maybe something like this?
We already tried this coding, but it gave an error indicating the B4XPages manager could not handle it when the code flow reach the highlighted line.
We are assuming that this is the wrong approach even though using StartActivity was what we thought was the logical choice. We also couldn't find out by searching the forum how everyone else is starting B4XPages from their service module.
All help will be appreciated.
We have a B4XPages app that includes a service module that starts with #StartAtBoot: true. Because B4XPages doesn't start upon a phone reboot, we would like to start B4XPages from that module when the user reboots their phone.
Maybe something like this?
B4X:
#Region Service Attributes
#StartAtBoot: true
#End Region
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(nid, CreateNotification("Tapping this notification will open the app."))
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
If B4XPages.IsInitialized = False Then
'Code to start B4XPages goes here'
End If
InitializeWhatsNeeded
End Sub
We already tried this coding, but it gave an error indicating the B4XPages manager could not handle it when the code flow reach the highlighted line.
B4X:
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(nid, CreateNotification("Tapping this notification will open the app."))
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
If B4XPages.IsInitialized = False Then
StartActivity(Main)
StartActivity(B4XPages.MainPage)
End If
Log("At service start.")
InitializeWhatsNeeded
End Sub
We are assuming that this is the wrong approach even though using StartActivity was what we thought was the logical choice. We also couldn't find out by searching the forum how everyone else is starting B4XPages from their service module.
All help will be appreciated.
Last edited: