Windows Phone 7 Development for Android Developers

Developing for the Windows Phone 7 Platform is more similar to developing for the Android Platform than you might expect. In this article, Chris Bennett explores the similarities between the two platforms. 


Download the Free Windows Phone 7 Tools

Much like mobile applications for the Android platform, Microsoft® Windows® Phone 7 (WP7) applications are written in a managed language—Java for Android and C# for Windows Phone 7—with accompanying libraries. Many of the differences between Java and Visual C#® are style related. The two modern languages share a common ancestry with the C/C++ languages and bear a strong resemblance to one another.

There are certainly differences between the .NET®/Windows Phone 7 and Java/Android APIs, but since the languages are similar you should be able to save much of the logic you have built in your existing application when porting your current apps over to Windows Phone 7. In fact you'll find it extremely easy to get started, as shown in the article, Windows Phone 7 for Java Developers.

Platform Differences
Before digging into the specific tools and processes for converting and/or creating applications for Windows Phone 7, let's begin with the terminology and technological differences between Windows Phone 7 and Android. The first big difference for Windows Phone 7 is that applications are created as managed .NET assemblies written in C#. The platform supports two types of applications—Silverlight® and XNA® games.

Most applications for Windows Phone 7 will be created in Silverlight, which provides typical form-based user interaction through common controls, such as Labels, Text Boxes, Lists, etc. The Android Layout and accompanying Activity is known as a Page in Silverlight.

The other type of application supported on Windows Phone 7 is XNA, which allows developers to create both 2D and 3D games. This is the equivalent of an Android SurfaceView and GLSurfaceView for 2D and 3D respectively. Unlike Android, which targets OpenGL for games, XNA games target Direct3D, which makes it easier to port PC and Xbox 360 games over to the phone.

Pages and Navigation
Silverlight Pages are created in XML files, similar to Android Layouts. The XML defining a Page is created in XAML (eXtensible Application Markup Language). XAML is similar to an Android Layout, but it allows for a wider range of features. XAML allows the developer to perform operations within the Page including Animations, Data Binding and more, eliminating the need for coding these functions.

The Android Layout is decoupled from the Activity used to perform the operation. As a result, you need to hand write the code needed to attach it to the user interface (UI) elements within the appropriate Activity. The C# code for a given Page is tied to the Page and is simply known as the code behind, so there is no need to hand write the UI attachment code. The platform automatically creates the necessary "wiring" for the objects and events for the Page and UI. This prevents the clutter typically occurring in the Task onCreate method where you attach to the UI and the various necessary handlers are created.

Another important area where the two platforms differ is navigation. In Android you switch from one task to another by creating an Intent. The equivalent within Windows Phone 7 is Navigation, which allows you to move between Pages. Similar to an Android Intent, you can pass data to the Page to which you are navigating. A Page within Windows Phone 7 has some properties similar to an ASP.net Page as you actually use a QueryString that allows you to pass information to the next Page.

Converting Layouts to Pages
Before diving into code, we need to look at the conversion of the Android Layout XML over to Windows Phone 7 XAML Pages. Certainly one of the high points of the free tools for Windows Phone 7 is the quality of designer tools available for XAML. The XAML designer included in Visual Studio® 2010 is intended to be used primarily by the developer to get the basic controls on the Page and start developing. Expression Blend® is intended to provide a design professional with a more advanced tool suite to refine the UI. As with an Android Layout, you can always resort to editing the XAML directly in the text editor, as it is an XML file.

A Windows Phone 7 Page provides similar layout capabilities and controls to Android Layout. The following table illustrates the layout options available and the Android Equivalent.

Layout Controls
Windows Phone 7Android Equivalent
CanvasAbsoluteLayout
Grid GridView
ScrollView ScrollView
StackPanel LinearLayout

As you can see, the Windows Phone 7 provides essentially the same types of layout capabilities. The following table shows the list of basic controls and the Android Equivalent.

Basic Controls
Windows Phone 7Android Equivalent
TextBlock TextView
TextBox EditText
ButtonButton
CheckBoxCheckBox
RadioButtonRadioButton
Image ImageView
ProgressBarProgressBar
ListBox ListView
Map MapView
WebBrowser WebView

You should notice that Windows Phone 7 does have a 1-1 match for the Basic Controls and the Layout types. Some of the specialized layouts and controls appear not to exist. The reason for this lies within the power of XAML, which provides the ability to very easily embed controls one within another. It is possible, for example, to add a ListBox with CheckBoxes next to each item without the need to write any code. This means that you do not need all of the complex built-in controls; those can be created and customized within your app.

  Next Page: Application Storage and Developer Tools
Page 1: Platform DifferencesPage 2: Application Storage and Developer Tools
Add to My MSN

Mobile Code Samples

22 new code samples cover nearly all the new features for Windows Phone 7.5 (Mango) including the most requested and hotly anticipated areas - camera, media, sockets, sensors, SL/XNA integration, Tile backgrounds and background agents.
Click here to download
Memory Profiling - The Heap Summary View
Delivering Rich Mobile Web Experiences in Windows Phone 7.5 (ESPN.com Case Study)
Four ways were improving Marketplace
Two Marketplace changes; An update on 9 new markets
Respond to User Input

Making Money with your Application on Windows Phone

Windows Phone: how to build a game

Building device & cloud apps

Windows Phone user experience design




Bryson Ewell
This young developer was inspired by his big brother. Find out how he learned to program and why you wont be seeing skydiving Sasquatches anytime soon...
Read More