Son of a Bit

01010011 01100101 01101100 01000001 01110010 01101111 01101101

0 notes

Quick Tip - Windows Azure Mobile Services and Xamarin

If you’re getting this error like I was:

A Windows Azure Mobile Services assembly for the current platform was not found. Ensure that the current project references both Microsoft.WindowsAzure.Mobile and the following platform-specific assembly: Microsoft.WindowsAzure.Mobile.Ext.
You should hopefully be able to resolve it with this single line of code to your initialization:
with eternal thanks to Chris Sainty for the fix!

Filed under xamarin azure mobile services

0 notes

Daily Code Snip: Display Remote Image via Uri in Android Xamarin

I needed to display a remote image in an ImageView in an Android app I’m building with Xamarin.

I discovered the method ImageView.SetImageUri which I tried to use in combination with Android.Net.Uri.Parse to pass it the Uri, but it turns out that this is not correct, at least not according to this thread on the Xamarin Forums: Image from Url in ImageView

Turns out you need to get a Bitmap by downloading the image stream and pass that to the ImageView to be rendered.

Here’s the code that accomplishes that (from the thread):

        private Bitmap GetImageBitmapFromUrl(string url)
     Bitmap imageBitmap = null;

     using (var webClient = new WebClient())
          var imageBytes = webClient.DownloadData(url);
          if (imageBytes != null && imageBytes.Length > 0)
               imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);

     return imageBitmap;

var imageBitmap = GetImageBitmapFromUrl("");

Apparently this is improved greatly in Xamarin.Forms, watch out for a future code snip on that (once I get to it)!

Filed under Xamarin Android ImageView Bitmap C

0 notes

Daily Code Snip: Launch Uri from Xamarin Android

I’m going to attempt to post something new everyday I had to learn or lookup. These are quick snips to accomplish simple tasks that anyone (meaning me!) can copy/paste into a project. It may not be daily, in fact I can pretty much guarantee it won’t be :)

Today I needed to launch the web browser when clicking a TextView in an Android App I’m building with Xamarin.

I found the solution here in the Xamarin Docs: Open a Webpage in the Browser Application

and here is a quick code sample:

View on Gist

I hope this is helpful!

Filed under Xamarin Android DailyCodeSnip c

0 notes

SystemMediaTransportControls and SystemMediaTransportControlsDisplayUpdater Crashing when updating thumbnail album art from Uri stream

While updating a Windows 8.1 Universal Store app which uses Background audio, I noticed that whenever I attempted to change tracks, the entire app would crash without any errors that I could find…

After commenting/uncommenting almost EVERY god damn line of code on the view, I finally narrowed it down to the SystemMediaTransportControlsDisplayUpdater which was attempting to update the Album Art from a remote Uri.

The strange thing is that it wasn’t failing to load the image, but rather it was just failing. If I set a break point to pause it for a moment, it would update without crashing and resume.

Fortunately before my flushed my laptop down the toilet I discovered this thread: SystemMediaTransportControlsDisplayUpdater.Update() causing transport control crash.

The workaround suggested was to add the following line of code to the update method:


You probably actually want to do this to the DisplayUpdater of the current view (SystemMediaTransportControls.GetForCurrentView()) but the idea is the same: before you run the update, clear it out!

I originally added this right before the Update() method but that apparently had the effect of updating with blank data.

Instead I put it above all the code that populates the updater and BAM no more mysterious crashing!

Thanks to the OP and I hope this is helpful!

Filed under Windows Store Apps Windows 8.1 Background Audio SystemMediaTransportControlsDisplayUpdater

0 notes

The SystemMediaTransportControls were initialized in a different mode. Please use the API associated with that mode to complete this operation.

While reading the Background Media docs at 2 am I confused myself and accidentally followed the instructions for Windows 8 in my Windows 8.1 app. Do NOT use the MediaControl static class to attach handlers for you Windows 8.1 app or you will get the error message:

The SystemMediaTransportControls were initialized in a different mode. Please use the API associated with that mode to complete this operation.
They really should move that sample to another page!

Filed under Windows 8 Windows 8.1 XAML Background Audio Event Handlers MediaControl