Mono Droid – Load Image Resource from Web

Alright – so you need to load an image dynamically as part of your Android Layout. You would think you can do this:

myImage.SetImageURI(Android.Net.Uri.Parse("http://bit.ly/Nsx0xn"));

But that won’t work. What happens? I’ll tell you. You end up with an error in the log that says:

Resolve Uri failed on bad bitmap Uri

This is because it is looking to resolve the Uri locally. So if your image is sitting at arms length (ie, on your SDcard or somewhere on the file system) then you need to work on getting that string to look right (there are plenty of google results on resolving this issue). But if you want to load it from a remote location (so you can change it without having to push out a new version of your app)

Change that line above to this:

var bm = BitmapFactory.DecodeStream(
        new Java.Net.URL("http://bit.ly/Nsx0xn").OpenStream());
myImage.SetImageBitmap(bm);

So hopefully this helps someone load an image they need loaded dynamically in their Android App that is in Mono Droid. There are some other complicated ways to load an image using byte arrays and stuff but why do all that when you can get the bitmap loaded with this method. I’d recommend only doing this with small images though – might start to run into threading issues and timing issues if you try to load big files from a remote location.

“Debug certificate expired” error in Eclipse Android plugins – Stack Overflow

“Debug certificate expired” error in Eclipse Android plugins – Stack Overflow.

It is amazing how incredibly useful posts like this can be for guys like me. Debug warning message was getting in my way – a quick google search takes me to stackoverflow.com and my problem is solved after a cursory skim of the page. Done. Love it. Takes 50 seconds to “Press This” to my wordpress and I never have to worry about this problem getting in my way again. Awesome. Love this workflow.

Got ADB Much?

Working much with ADB? I have been spending WAY TOO much time with it. It is the Android Debugging Bridge.

Some of the most useful features I have come across to get files moving around are these:

adb pull <remote file> <local file>

– and –

adb push <local file> <remote file>

Invaluable. Like FTP, but very fast and convenient. Hope that helps someone!

Set progress bar drawable – Android Developers | Google Groups

Set progress bar drawable – Android Developers | Google Groups.

Today’s lifesaver. When writing an app in Mono Android, you will need to set your ProgressDrawable = Resources.GetDrawable(Resource.Drawable.drawablename) to get your ProgressDrawable setting to be the drawable xml you have defined. This is how we can setup custom colors for a progress bar.