I learn MVVM in android. I can't understand why never mention services? Now my app looks like activity <-> viewmodel <-> repository <-> dao. For example i want to synchronize date from Firebase every 4 hours. Where i should check time and load data?
Asked
Active
Viewed 479 times
4

sergkk
- 118
- 10
-
Try to add some code or snapshot or anything else, where you have stuck that community can understand better to respond. – Shahadat Hossain Jul 11 '19 at 06:06
1 Answers
1
You can user the latest android architecture component
WorkManager
to schedule your job every 4 hours and sync data with firebase.
As of to your confusion, ViewModel can contain the business logic, But again these can always be tweak as per our need, for example, if you need to do UI operations from the service you might have to bind the service to activity, in that case the code will direclty be written into activity or so.

Hardik Chauhan
- 2,750
- 15
- 30