Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

XLabs IMediaPicker on Android not working

$
0
0

I'm really struggling to get access to the camera and photo library when using XLabs in my PCL project. Things work perfectly on iOS but Android is simply not working.

In my Android MainActivity.cs file I setup IoC as:

        public void SetIoc()
        {
            if (Resolver.IsSet) {
                return;
            }

            var resolverContainer = new SimpleContainer();

            var app = new XFormsAppDroid();
            app.Init(this);

            resolverContainer
                .Register<IDevice> (t => AndroidDevice.CurrentDevice)
                .Register<IMediaPicker>(t => t.Resolve<MediaPicker>())
                .Register<IXFormsApp>(app);

            Resolver.SetResolver(resolverContainer.GetResolver());
        }

And in my PCL code when I try to access the photo library or camera I have the following which throws an exception:

var device = Resolver.Resolve<IDevice>();

// Hack for working on windows phone (from XLabs source code samples)
_mediaPicker = DependencyService.Get<IMediaPicker>() ?? device.MediaPicker;


System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'XLabs.Platform.Droid'

Changing the _mediaPicker assignment to the following results in a NULL return value:

var mediaPicker = Resolver.Resolve<IMediaPicker>();

Is it possible that my version of Android is not new enough for XLabs to work? My HTC handset is using Android v4.0.3. Do I need something >= Jellybean? Can anyone point me in the right direction?

Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>