Review in :
http://www.codemag.com/Article/1308051
Mastery of mobile platforms makes you a better developer and can really give you more job opportunities. But let’s face it: The list of mobile platforms that offer more healthy prospects doesn’t yet include Windows Phone and Windows 8. Your outlook is just plain better if you can code for iOS or Android.
Your outlook is just plain better if you can code for iOS or Android.
As a seasoned .NET developer with a strong background in C#, what’s the easiest approach you can take to become a better mobile developer? In this article, I’ll show you the way to Android programming.
In many ways, the Android is an easy catch for .NET developers. First and foremost, the programming language is either C#, if you opt for writing apps through the Mono platform, or Java-a close relative to C#-if you take the classic route of the standard Android SDK. Second, you don’t need to buy a Mac in order to develop for Android. Whatever IDE you choose to use is available for Windows too. Finally, the user interface of Android apps is laid out using an XML schema that doesn’t look foreign to people who know XAML.
Compared to developing for iOS or even Windows Phone, Android programming is challenging for one notable reason: the huge number of significantly different devices that may be running your application. You can find Android on an $80 cell phone as well as on a high-end $500 smartphone. The difference in terms of power, battery, resources, and screen size can be huge. These variables add more work to the schedule and, even more than that, it adds forethought: you must plan your Android effort well for it to result in a success story.
Compared to developing for iOS or even Windows Phone, Android programming is challenging for one notable reason: the huge number of significantly different devices that may be running your application.
Far from the ultimate resource for all aspects of Android programming, this article aims modestly at providing practical information to get you started and creating functional test applications.
Options for Android Development
The primary approach to Android programming consists of downloading the Android SDK and writing your apps using the Java programming language. This approach guarantees the fastest and most compact apps, and this is the approach presented in the rest of this article.
If you’re a .NET developer, though, you might want to consider another option: Xamarin Studio from Xamarin. Note that Xamarin Studio (formerly MonoDroid) is a commercial product and may require you to buy a license. (For more information, have a look at http://www.xamarin.com.)
You can use the Xamarin Studio IDE (formerly MonoDevelop) on a Windows computer or you can install an extension to Visual Studio and keep using all of your favorite plug-ins.
An Android application built with Xamarin Studio executes within an instance of a Mono-based virtual computer. The Mono virtual computer, in turn, lives side-by-side with the Android’s virtual computer. To access native Android functionalities, you use a bunch of classes that look like classes in the .NET Framework except that they bind to the Android API under the hood.
To access native Android functionalities, you use a bunch of classes that look like classes in the .NET Framework except that they bind to the Android API under the hood.
The build of a Mono-based Android application passes through four steps: processing resources from Android resource files into .NET-compatible resource files; creation of the .NET code; processing of the .NET code to create Java wrappers; and final packaging of the Android executable.
In my opinion, the primary reason for using Mono for Android resides in the possibility of a quicker startup time as you can stay in Visual Studio and write in C#. However, the final application is a bit larger because of the extra Mono runtime. For an Android application, size may be an issue much more than for an iOS or Windows Phone application because of the wide range of different devices out there with very limited memory capabilities.
Another good reason for going Mono is that you can reuse some code across multiple mobile platforms. If you need to have an app for iOS, Android, and even Windows Phone, it’s likely that you can reuse some code.
Note, though, that this last point, while remarkable, is actually much less appealing than it may sound at first. The code you can reasonably reuse in a Mono-based set of mobile apps is only the business logic code you run on a device. The presentation layer of Mono-based Android applications must still closely reflect the philosophy and behavior of Android activities. You must know this in order to effectively write Mono-based Android applications. (And the same holds true for Mono-based iOS apps.) Making sense of the presentation logic of mobile platforms is the hardest part of writing mobile apps.
The code you can reasonably reuse in a Mono-based set of mobile apps is only the business logic code you run on a device.
Another option for writing Android applications is PhoneGap (see http://phonegap.com.) An app built against the PhoneGap framework is a classic client-side Web application made of HTML5 pages using CSS and JavaScript. You write and test the application within your favorite development platform, and using your favorite tools. For example, you can use Visual Studio or perhaps JetBrains’s WebStorm or any other text editor for the HTML pages and JavaScript logic. Once the Web core is ready, though, you have the problem of packaging that into a real Android application. You need an IDE for that like Eclipse or JetBrains’s IntelliJ IDEA. eOr, you can leverage the PhoneGap Build service (see http://build.phonegap.com) and upload your app to the service for packaging.
If you opt for doing it all by yourself, then you end up with a plain Android project in an IDE that supports Android development. Because the entire application is HTML and JavaScript, though, in this case, your exposure to Java and manifest files is minimal, although not null.