Search code examples
androidandroid-intentmvvmcross

mvvmcross android intent plugin


I need to do something similar to this, actually I just want to fire an intent and receive the result from a hardware barcode scanner.

Where to listen for broadcast action with MVVMCross

Which plugins(s) should I add in order to get Intent and MvxAndroidTask?

I can see Intent defined in Mono.Android but I don't know how to get that into my .Core project.


Solution

  • I can see Intent defined in Mono.Android but I don't know how to get that into my .Core project.

    You can't add Intent or MvxAndroidTask to your Core PCL project - they are not portable classes - they are Android specific.

    If you are only implementing Android, then you can use an Android specific class library for your ViewModels - and then you can use Intent and MvxAndroidTask.

    More likely, if you are implementing shared portable ViewModels, then you will need to use Dependency Injection to allow the ViewModels to interact with platform specific features. One technique you can use for this is "Plugins" - see https://github.com/MvvmCross/MvvmCross/wiki/Plugins

    One person who's already done some Barcode scanner integration work is https://github.com/aritchie/acrmvvmcross