문제

My problem is that I want the application to download some information from my database every week. This is like a new promotion every week and will be updated on the database every Friday.

I know how to check what day of the week it is using the calendar.

But I don't know how to find out when the next occurring Friday will be.

Is it possible to do or should I just make it a weekly check starting the day the application was installed?

도움이 되었습니까?

해결책

Store the timestamp of your last update in SharedPreferences. Use AlarmManager with INTERVAL_DAY. When it wakes up your app, check if it's Friday, or has been more than 156 hours since the last update. If it is, run your updates.

Alternatively, check the last update time when launching, and if it's been more than a x days since the last update, update then.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top