Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

What You Need to Know Before You Start Developing Windows Phone Apps

DZone's Guide to

What You Need to Know Before You Start Developing Windows Phone Apps

Developing for the Windows Phone is easy, but if you plan on developing for Windows Phone 8.1 and 10, there are some important things you should know.

· Mobile Zone ·
Free Resource

To start Windows Phone development is very easy and there are so many tutorials out there that show you what you need to do. However, soon after starting, you will realize that there are many platforms, SDKs, and different assemblies. This means that you will often find ways to doing certain things (in blogs, tutorials, etc) that would not work in your environment, and the reason for that is the difference between these platforms. In all honesty, it is a big mess that Microsoft is currently trying to clean up by unifying the teams and bringing up a universal platform.

This makes it extremely essential that you learn about the different platforms and options available for you before you start developing for Window Phone. This not only impacts what devices and platforms you are targeting, but it also impacts how you do things. To give you an example, when you search for a simple task such as getting the name of a device (or its unique Id), you will find few sample code snippets that would allow you to do that on Windows Phone 7 and Windows Phone 8. However, when you try to do the same things on Windows Phone RT (XAML/Universal apps), you will soon hit a block to find that these SDKs/DLLs do not exist. Thus, you need to learn about the differences in the platforms and the SDKs that you are using.

Fortunately, there is a very nice and visual list of all the libraries and the differences in the SDK, you can find it here. This shows you the differences between the 2 main different SDKs in Windows Phone 8.

WindowsPhone (Silverlight) vs WindowsPhone RT (Universal)

To give you an example of how things are radically different, let’s take a simple task of finding the device Name and unique Id.

In Windows Phone 8.1 (Silverlight)

Here is how you do that in Windows Phone 8.1 (Silverlight) and its predecessor Windows Phone 7.

byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string DeviceIDAsString = Convert.ToBase64String(myDeviceID);
MessageBox.Show(DeviceIDAsString);

In Windows Phone 8.1 (RT/Universal/Store Apps)

Here is how you do the same thing in Windows Phone 8.1 RT/Universal/Store Apps.

private string GetHardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);

return BitConverter.ToString(bytes);
}

As you can see, the code is totally different for doing the same task, plus the libraries that you would expect to call would not be there in Windows Phone 8.1 RT. To make things more tricky, if you search “How to get a unique device id in Windows Phone 8.1” you will get these results in Google, which all leads you to how to do these tasks on Windows Phone 8.1 Silverlight. There are examples of the results here and here.

How to Get Device Unique Id in Windows Phone 8.1

Moving forward, you should not attempt to write things in Silverlight, as it is a dying technology. You should always aim at targeting Universal apps in Windows Phone 8.1 and Windows 10. This not only gives you the ability to work on the latest tools/SDKs, but it also enables you can to reach a wider audience by giving you the ability to support other platforms (Windows PC, Xbox, etc).

So in conclusion, if you are starting to develop for Windows Phone, please please do have a look at the SDKs and learn the differences before you start diving in. And, when you are developing and you need to find how to do certain things in Windows Phone’s world, be sure to search for the SDK/Platform that you are using. As of now, most of the search results on StackOverflow or the results in Google Search show you how to do things in Windows Phone 7/8 Silverlight, which would not work for you mostly likely (if you are targeting Win RT/Universal/Store Apps).

Topics:
mobile ,mobile app development ,windows phone ,universal ,silverlight

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}