What is the right place to start a service in MVVM

2019-03-29 07:53发布

I just started using MVVM architecture on Android. I have a service which basically fetches some data and updates the UI and this is what I understood from MVVM:

  • Activity should not know anything about the data and should take care of the views
  • ViewModels should not know about activity
  • Repository is responsible for getting the data

Now as ViewModels should not know anything about the activity and Activities should not do anything other than handling views, Can anyone please tell where should I start a service?

1条回答
▲ chillily
2楼-- · 2019-03-29 08:09

As far as I know, Services are Android related so, they could be started from View (Activity/Fragment/Lifecycleowner).

查看更多
登录 后发表回答