Android Question Using Services to register person's location periodically

davidvidasoft

Member
Licensed User
I am developing an app that, once started, should capture the current location of the person using the app and register it in a external database; and the app should also repeat this action every minute. This is for tracking the user(a product seller that follows a designed route of clients) on a map. Also, at some point the user(seller) may want to store the current location of the client he is visiting at the moment.

Now, I am having problems with the way I should implement the timer for my service. I have found many tutorials on this forum but I think some of them, if not the mayority, are outdated since there has been some changes in the way new Android versions are implementing many things like services and foreground services, notifications, etc; and changes also with new B4A versions.

So, I want to know which would be the best way to implement my first use case, capturing the location of the user every minute. I know that it has to be a foreground service since I don't want it to be randomly killed by the OS and it should continue recording even when the application is pause. I followed Erel's GPS Tutorial and have successfully implemented it in my app for my second use case, saving the current location of the client the user is visiting at the moment, case but I am not sure on how to combine it with a timer to fullfil my first requirement.

Sorry for any grammatical mistake, I'm not native to the language.
Any help is appreciated.
 
Last edited:

Pooya1

Active Member
Licensed User
Hi
Use StartServiceAt for run service in every 5 minute
Also use Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS Use this code in end of service that you get location there
And after finish service's job,use Service.StopAutomaticForeground
 
Upvote 0
Top