Mono for Android memory management tips

Building applications with Mono for Android is fun, I kind of like having the full Linq API, the task parallel library and the rest of the .NET framework at my finger types. Java is great too, but it isn't my primary programming language, so I am missing a few tricks to get the most out of it. So C# and Mono for Android is the way to go even if I do Android-only development.

There's also a downside to using Mono for Android. And that is exactly the thing I'm not using, Java. Because you're working in a universe with two garbage collectors and two typesets, you're constantly balancing on a very thin line. If you go too wild with your code you will make one of the garbage collectors upset and your app will crash. It can be a rather frustrating experience.

Using C# to take pictures with your Android phone

<p>Taking pictures with a phone is probably the number one thing people want to be able to do when they start building apps for Android. It's not that tricky to get working properly, but there are a few things you need to know to get the whole circus going. </p> <p>In this post I will be showing you how you can take pictures using your Android phone right from C#. Keep in mind this assumes you know C# and Mono for Android. I'm also assuming you know a little about Android and how you should build a basic app for it using C# and Mono for Android.<!--more--></p> <h2>Taking the picture</h2> <p>The first step is to take the actual picture using the camera provided by the device. This is done by invoking the camera activity using an intent. Intent in Android can be seen as the asynchronous messaging system to send data between apps on the device. You can use intents to start activities, services or query content providers.</p> <p>To take a picture you need to use the "capture image" intent provided by the Mediastore class that is part of Android. This is done from the current Activity class. The following code sample demonstrates the use of this intent. </p>

private void TakePicture()
// Specify the message to send to the OS
var takePictureIntent = new Intent(MediaStore.ActionImageCapture);
// Start the requested activity
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
base.OnActivityResult(requestCode, resultCode, data);
if(requestCode == 1001 &amp;&amp; resultCode == Result.Ok)
//TODO: Do something useful with the image.

Using OData with Mono for Android

OData is popular these days and a protocol that is very easy to use. It's a way to expose a model in a resource oriented way to clients. There's support for Windows Phone 7, Silverlight and Windows but not Mono for Android. Now that I have grown a liking to Mono for Android I thought it might be cool to convert an existing version of the OData client library to a Mono for Android version.<!--more-->

<!-- more -->

Prototyping mobile applications

Mobile is kinda controlling my life these days. Not a lot of Silverlight going on at least. I don't mind really, because I think it's great working with Marcel de Vries and Roy Cornelissen on some very cool apps. It gives me ample opportunity to do something completely new.<!--more-->

I've been discovering the wonderful world of prototyping applications. For me this is new, because I've always used use-cases, user stories and other written techniques. But ever since I started working with Marcel and Roy on mobile apps we've been using prototyping techniques to get from a general idea to something that we can build. <h2>The reason to use prototyping</h2> The reason to use prototyping is simple. Use-cases, user stories and development specs are precise, mechanic and kind of right-brain oriented. This is fine when you need to finalize the design of the application. Also these are all great techniques when you need a formal design to drive the implementation process. I would use these techniques any time if I needed to get a team of developers to finish a product.

Making java libraries available to Mono for Android

While doing a bit of research for a new app I came to the conclusion that I needed some kind of charting library for that app. Looking around the internet I quickly discovered that there's nothing available right now for Mono for Android. There is however a good library available for regular Android development using Java.

The guys at have a very complete library for Android available, that does pretty much what I need. So there I am sitting at my desk, thinking. There's two options: I write a full port of the library for C# or bind the library. The first option is what most people would do. It's straightforward to program, but a lot of work. Also, you will miss out on all bugfixes that the guys over at achartengine might come up with. That leaves option two, bind the library to C#.

Designing cross platform mobile apps

Making an app that works on iPhone, Android and Windows Phone 7 is tricky. Each of the platforms is different from the others in many ways.

The most obvious thing about iPhone, Android and Windows Phone 7 that's different is the user interface, which is different on all platforms because all of the platforms want to stand out and entice the user into choosing that platform. There's even more going on under the hood. Each of the platforms not only has its own user interface components with matching patterns, there's also a whole host of other things that is different. Most of the differences however have to do with the way the devices were build. Android, iPhone and Windows Phone 7 all have access to telephony, GPS and internet, but all of them do it differently.<!--more-->