I recently got myself an Android mobile phone and was really interested in writing applications for it. After downloading the Android SDK as well as the 32-bit Java SDK (noooooo!) I got it all installed and running the sample apps with Eclipse and browsed around the code.
Firstly, I wasn’t really too keen on getting into another development environment. Secondly, I really didn’t want to do any Java development if I didn’t have to. C# is my happy place, C++ is for the ugly stuff if you need it, Java is just, well, ugly... Besides the last time I did any serious Java was in college, enter MonoDroid to save the day!
To get everything installed read this guide. Then you can read about the API and architecture to get a better understanding about how it all gels together. Pretty much everything you need including signing up for the newsletter can be found by going directly to www.monodroid.net.
Once you have everything installed it’s pretty easy to get going. The beauty about diving in using a language you are familiar with, means you can get used to the Android SDK without having any knowledge of Java or even C++ (for more advanced features). MonoDroid wraps up all the calls using standard .NET constructs through a JNI bridge, plus, you get all of the power of the standard .NET API’s which work in Linux/Android.
Following the tradition of “Hello World”, let’s jump right in and write an Android application.
- Make sure that you have everything installed, this guide couldn’t have made it easier.
- Create a new Project in Visual Studio:
- MonoDroid does most of the heavy lifting for you. If you’re familiar with Android projects in Eclipse you should have any problems with the structure. Android uses layout and string resource files (the right way) for the UI. Activities are like UI controllers, all the info you need is on the Android Developers website.
- Just run the application to check everything is working correctly, if you don’t have a device attached or an emulator running then now is the time to create one:
If you don’t see anything then just click “Start emulator image”:
Once again MonoDroid holds your hand by signing the package and also installing the Mono runtime if it’s not already available.
WARNING: If you are running an emulator then this will take a while, if you have a monster PC that does it in seconds then I hate you.
- Unlock the phone/emulator and click the button:
That’s it! There is a lot of documentation on writing Android applications. Java isn't that far off in syntax to C# so it will be easy to pick up sample code all over the place.
The best place to start is the MonoDroid API design documentation. Do yourself a favour and browse the classes in the Android namespace. Make sure you check Android.Provider which gives you access to things like Contacts, Settings, Calls Logs etc. through static classes.
This Justin guy slicked the domain www.mono-droid.com in July 2010 already so this isn’t new, just widely available now and free for the time being. There is a lot of useful information on installing and developing here. He’s got videos too, everyone loves videos.
Android, C#, Mono, MonoDroid, Visual Studio