Roger's Blog | Well, I think it's interesting.

Apr/10

14

Experimenting With Android – Part 1

At the end of 2009 I found myself with a little too much free time and started looking for something new to experiment with. I’ve always been interested in mobile development but I don’t own a Mac or an iPhone nor do I have any interest in purchasing one. I had read an article about Android and was starting to think about a new phone so I started looking at the Android SDK. There’s no fee to download the SDK or any of the tools.

Developing for Android requires writing code in Java and designing screens (called Layouts) using XML (although layout elements can be created all in code if you wish.) I’ve never programmed in Java before but Java and C# are so similar in syntax and there is such a wealth of information on the Internet about Java that I found it very easy to learn the basics. Also, the concept of designing layouts using XML is very similar to designing WPF and Silverlight UI’s in XAML.

To start Android developing you need a few things (all the details are at http://developer.android.com/intl/fr/sdk/requirements.html and http://developer.android.com/intl/fr/sdk/installing.html.)

  • A PC running Windows XP, Vista, or Windows 7 (32bit or 64bit); Mac OS X 10.5.8 or better; or Linux. I’ve been using 64bit Vista and 64bit Windows 7.
  • The Eclipse IDE version 3.4 or 3.5
  • The Eclipse JDT plug-in.
  • The Java JDK 5 or JDK 6 (the JRE isn’t enough, you need the full dev kit.)
  • The Android Development Tools (ADT) plug-in. This isn’t strictly required but it does make life easier.
  • Apache Ant (http://ant.apache.org) if you want to be able to build from the command line or if you want to use a continuous integration server. Yes, Ant is where the .NET tool Nant came from.
  • The Android SDK itself.
  • SDK Add-ons (mainly the Google Maps API) and the USB driver for Windows. The driver allows you to run and debug an application on an actual Android device but isn’t required if you don’t have a device or are using an OS other than Windows.)

You need 500MB of additional disk space for the SDK tools, platforms, samples, and offline documentation plus additional space for each virtual device you create. Each platform targets a different version of the Android OS and you must install at least one platform. If you don’t have an Android device you’ll need to create at least one Android Virtual Device (AVD). When you create an AVD you’ll specify which version of the Android OS it will run and how large the SD card will be. If you create an AVD with an 8GB SD card the emulator will create an empty 8GB image file that represents the SD card so plan disk space accordingly.

I won’t go into the details of installing all the pieces because the web site has excellent step-by-step directions.

So what have I been doing with it? Well, I started with the tutorials of course. The ubiquitous “Hello, World" tutorial does a good job of walking you through all the steps needed to build an app. The “Hello, Views” tutorial has several examples that highlight the different base layouts and views. “Hello, Localization” talks about using resources to localize an application and “Notepad Tutorial” goes step-by-step into writing a notepad application.

In March 2010 at the Microsoft MIX conference one of the announcements was about the Open Data Protocol and one of the partners was Restlet and their Java extension for OData. Restlet has a version of the library for Android. One of the things it will do is query the metadata from a .NET WCF service and generate all the service refs and POCO, excuse me, POJO objects similar to using “Add service reference” in Visual Studio. I started using Restlet to query the Netflix OData feed that was demonstrated at MIX but discovered some problems with the Restlet library that made working with the Netflix feed difficult (Restlet is in the process of fixing the problems.) Then I saw a tweet from Chris Woodruff (Woody from Deep Fried Bytes) that he had made a database of baseball statistics available via an OData feed. For the last couple of weeks I’ve been working on a demo Android app that can search this database by player last name and display player details, batting, fielding, and pitching stats. In the next post I’ll start showing the application and talk about what mistakes I made and what I learned while building it.

No tags

<<

>>

Theme Design by devolux.nh2.me