I would like to create a background service on the mobile device so it runs upon boot up and records the GPS location of the device. Is there a way within B4A to set the app to start at boot and also to check if it's running from another app and start if not? The background app just needs to run every 30 minutes to report the location and wait until the 30 minutes expire. I've reviewed the StartServiceAt but don't see a clear way to create as a separate app and kick this off on boot up.
to program next reading 30 minutes from now.
If you need to save GPS data to a remote server or plan to perform a long lasting action, consider reading about PartialLock.
I created a separate app with a new service module and added this code. I then put into the Service Start to send a message, just so I can see that it's working first.
I am not getting any message to show.
I still needed the main module so that I could name the project, does that matter?
It appears I have it running and I didn't restart the device to make sure it started during bootup.
Yes. You must start it by code (via activity). The idea is to let the user know (= start an app) what happens on his device. An service is like a "sub". You start it by code and it executes some code. If you want that every x time, you must schedule it with "StartServiceAt" like udg posted. Android takes care that it will be started then. It's not that accurate. Search the forum for other possibilities or changes from Android 8 or so.
Okay, I think that worked. But in the service to test the process I had a Msgbox set to show in Service_Start. This causes the app to crash. Is it because I'm trying to display a Msgbox within the service itself?
Okay, I think that worked. But in the service to test the process I had a Msgbox set to show in Service_Start. This causes the app to crash. Is it because I'm trying to display a Msgbox within the service itself?