Background Distancing

I have been trying to get the time and distance of travel in the foreground service that is when the app is in the overview tab and not is interacted by the user. I can calculate distance and time while the user is interacting with the app but not when the user is not interacting with the app and app is in the overview tab.
Thank you in advance.