You can use AlarmManager to display specific actions at a given time. AlarmManager will ensure that the activity or service, if you like, is launched, even if the application is not open at that time, and AlarmManager also compatible with the battery
First of all, you need to get an instance of AlarmManager:
myAlarmMgr = (AlarmManager) this.getSystemService(ALARM_SERVICE);
and then you can schedule an action to be displayed periodically or only once:
myAlarmMgr.setInexactRepeating(AlarmManager.RTC, _whenToStart, _intervalIfAny, _PendingIntentToStartActivityOrService);
See AlarmManager documentation for more details.
source share