Service in the background android oreo



Good morning, a query know what can be the best way to implement a service that runs in the background, basically I need to get the user’s location every so often, but I understand that in android oreo services is second plane have restrictions and they must be created in a special way so that the system does not stop them. I want to use something that works as much as possible in all versions


Check this example,