The situation: I'm a recently graduated IoT dev (c/cpp) that got hired to work on a small company's mobile application (among other things). This app is being developed only by me, being the only local dev, and written in Kotlin. So my skills are limited as is my understanding of the dept of Object Oriented Programming.
The Program: My task is to develop an app that tracks location and created geofences around certain points. Both of these I've managed to imply successfully. Both of these functions have the capability of functioning when the screen is locked, or the app is moved to the background. I'm using a mutableLiveData object to gather info and send it to a 'post' function. Which all work when the app is active on the foreground and the screen unlocked.
The Issue: All works fine as long as the app is active, yet when moved to the background or with the screen locked the observer doesn't seem to actually send over data to the post function. It does this when the app is activated again in the foreground. I have come to the understanding that this is how livedata observers work, and I'm at a loss as to what could be an alternative here.
What I am looking for: I need to figure out a way to gather different variable data in an object that I can send to a remote HTTP endpoint when the app is in the background or the screen is locked, like livedata observer but for background activities.
LiveData works only while the Activity is RUNNING, so when the App is in Background or in Paused state LiveData will not trigger anything.
For background tasks you can use Services or Threads but it's different approach completly by using Binding or Messages that could be a bit complicated for new programmers.