This project explains How to update the Data when application is either in foreground/background.
Which supports till version android pie.
To Check the Output can u please first set with your ip address as base url in build config field in build gradle by replacing with my ipaddress.