What is the correct way of fetching data from web api periodically in background even if android app is closed? : I want to create an android app which should fetch data from a WEB-API after equal intervals of time (lets say after every five minutes) even if my app is closed. Also it should generate the notifications if new data is fetched.

What is the correct way to do it ??

Do I need to you background service and call a thread from onStartCommand and fetch data in that thread with some sleep time ???