I'm looking to make an application that runs in the background, logging location data without the user actually having to have the application in the foreground but at the same time doesn't use too much battery.
I originally thought of setting a BroadcastReceiver for BOOT_COMPLETED and run a service which uses a Significant Motion sensor to log location data whenever the it fired off, but ever since Oreo, there are alot of limitations on background services.
What is the best way to do this?
You can use
JobService
it's efficient in terms of battery and modern way to perform the task in the background.and you can configure it the way you want it like this
For more detail refer this Intelligent Job-Scheduling