MvvmCross DataService in an Android Broadcast listener

半世苍凉 提交于 2019-12-31 01:54:09

问题


I am currently venturing into the MvvmCross realm and making some good headway, but ran into something that I have been unable to figure out on my own. I currently have an android service that is going to be running all the time. That service is going to be started either on a system boot or when the application first fires up.

That service/broadcast receiver will need access to the DataService that is created in a PCL project with MvvmCross. I have not been able to figure out how to get the instantiated data service into that service/broadcast receiver on creation of the service since there are not any view models that are associated with the service.

I know that it's probably relatively simple, but I haven't been figure it out on my own.


回答1:


The easiest way to do this is probably to just request that the full Setup is completed during the first part of OnCreate for your service:

        var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
        setupSingleton.EnsureInitialized();


来源:https://stackoverflow.com/questions/19844889/mvvmcross-dataservice-in-an-android-broadcast-listener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!