Introduction

This will be a series of blog entries where I discuss the Xamarin platform for Android.

I really enjoy C# programming language (JavaScript second)….Linq, Generics, anonymous methods, and Visual Studio are just some of the reasons I like it. Xamarin is a platform that gives you the ability you to write Android applications in c#.

When I heard about Xamarin I naturally, wanted to give it a shot. Having tried Eclipse, and Android Studio for android development I was no idiot when it came to the platform. So I got a license, and did nothing with it for six months, until a few weeks ago. After only 3 days I created Ultimate Gravatar Sync. An app that sync’s your contacts gravatar images to their picture in your phone.

C# with no compromise

The Xamarin platform uses mono, and some kind of voodoo bindings to the Java libraries to make it work. I wont go in depth, but the native features of the C# language are there to use. I never felt like my hands had been tied, that all of a sudden I couldn’t use a library that is normally part of the GAC.aspx) (Global Assembly Cache). When I needed multi-threading, System.Threading was there, and when I needed to use C# Generics I had no issues implementing them.

Xamarin execution

Manage Android Manifest files

One of the things that blew me away about the platform, was that I never had to add anything to my manifest file. For those of you whom don’t know, Android requires an XML config detailing the permissions you require, and the classes you have in your application.

Simple decoration such as:

1
[Activity(Label = "Label", MainLauncher = true, Icon = "@drawable/Icon")]

Will Generate in your manifest file as:

1
2
3
4
5
6
7
8
9
10
<pre>
<activity
android:label="Label"
android:name=".logoActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</pre>

Adding permissions is also easy:

1
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]

Using Java Libraries

Xamarin provides some kind of crazy visual studio project, that will essentially provide c# bindings to Java libraries you require. To bind Simply create a Java Binding project, adding the .Jar files, and then build. Watch the magic happen. They do note/) that you sometimes need to do some configuration for certain libraries, however I had no issues with the one I tried. On top of that if you really needed to, you could access the Java Native Interface for even more power.