Introduction to Xamarin | The new world to Cross platform Development.

Xamarin is a platform that allows us to build Android and IOS Apps using C#. This helps easy migration for .Net developers to Android developers. Xamarin offers two commercial products, MonoTouch and Mono for Android, also known as Xamarin.iOS and Xamarin.Android, respectively.

Xamarin installer can be downloaded from Though the cost is $999 per year, a 30 day trial can downloaded for tutorial purposes. Xamarin installer installs the following.

  1. Xamarin.Android for Visual Studio
  2. Xamarin.Ios for Visual Studio
  3. Xamarin Studio


The image (Image 1) shown below depicts the Product Selection screen upon clicking the installer.

Introduction to Xamarin

Introduction to Xamarin

Xamarin Studio is a modern, sophisticated IDE with many features for creating iOS and Android applications. It includes a rich editor, debugging, native platform integration with iOS and Android. Apps can be developed using Xamarin Studio as well as Visual Studio.

This document assumes Visual Studio is used for development though the processes in both are almost the same.

Xamarin.iOS requires a Mac to be connected somewhere within the network. Xamarin.Android works within the Windows system.

How to build an Android app using Visual Studio

Once Xamarin.Android is installed, open VS2012 and select New Project (Refer Image 2).

Project Selection Screen

Project Selection Screen


We can see under Visual C# Template on the left panel in the Project Selection screen, there are options Android and iOS. A new android application can be created by selecting “Android Application” from new project.

Below is the solution explorer (Image 3) for a sample Hello world Android App created in Visual Studio.

Solution Explorer

Solution Explorer


In the image 3 you can see 2 class files FirstActivity.cs and SecondActivity.cs. Activities are the fundamental building blocks of Android Apps. When an App is launched the Main Activity is loaded. The screenshot titled Image 4, is the source code for the default activity


An activity is defined by inheriting from the Activity class. In the above example the class FirstActivity inherits Activity. TO define a Service the class should be inherited from Service.

The UI can be defined within the code or in an xml file. The file extension for the xml is axml (android XML). In the above code the Resource.Layout.Main axml file is loaded. Image 5 below shows the life cycle of an Activity

Activity Life CycleImage Courtesy |

Activity Life CycleImage Courtesy |



For Database operations SQL Lite is used in Android. In Xamarin.Android all database operations are defined within the namespace Mono.Data.Sqlite. This namespace has the classes SqliteConnection, SqliteCommand etc.

Leave a Reply

Your email address will not be published. Required fields are marked *