You can't and shouldn't update the UI while in the background. Your best bet would be to set a threshold on the background data recording. While within the threshold, "catch-up" the UI when entering the foreground. When outside the threshold, reset the UI on entering foreground. When the threshold is crossed, data should be maintained to be enough for just a reset (not the whole history). Pre-threshold, maintain it all.
App Flow:
- App Launch
- Collect and Display Data on Overlay
- App Background
- Continue Collecting Data
Then onForeground:
if (appForegroundBeforeTooMuchData) {
//Update Overlay
} else {
//We have too much data to update the overlay smoothly, store the data and start a *new session* on foreground
//Behave as if user just started the app
}