Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvvmCross DataService in an Android Broadcast listener

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.

like image 654
Chaitanya Marvici Avatar asked Nov 18 '25 11:11

Chaitanya Marvici


1 Answers

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();
like image 77
Stuart Avatar answered Nov 21 '25 07:11

Stuart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!