31 Days of Mango | Day #1: The New Windows Phone Emulator
Join the DZone community and get the full member experience.Join For Free
This article is Day #1 in a series called 31 Days of Mango.
In Day#1, I thought it was important to note some awesome new additions that have been made to the Windows Phone Emulator, and how and when we can use them. In short, we now have the ability to emulate Accelerometer and Location data in our apps.
Accelerometer Data Tool
In order to emulate Accelerometer data, you first need to write some code that taps into the Accelerometer. Fortunately, Day #11 of the 31 Days of Windows Phone provides that exact example.
Once you’ve got it running, you should see an interface that looks like the image below. To access the tools in the emulator, you need to click the arrow icon on the menu for the emulator:
When you click the arrows, you will bring up a second window where you can access the tools we’re interested in.
In order to feed accelerometer data into your application, all you need to do is click and drag the small red circle in the center of the screen. It will rotate the image of the phone in 3D space, allowing you to pretend to shake, flip, or even spin the device. Here’s another look at this tool, with the phone moved dramatically.
You can see that your application should be responding accordingly. To reset the phone to its original position, or to choose a different standard position, you can use the Orientation drop-down in the bottom left corner.
Finally, if you want to emulate a random shaking motion, you can use the drop-down list on the bottom right, labeled “Recorded Data.” For now, Shake is the only option available, but ultimately, you will be able to create your own recordings and replay them.
Location Data Tool
The second tab in the Windows Phone Emulator Tools is for location data. In order to monitor your Location data, you can use the code from Day #13 of the 31 Days of Windows Phone.
When you open that tab of the tools, you will see an interface that looks like this:
By default, the Location tool will always start centered on Microsoft’s headquarters. In order to change your location on the map, you can zoom in or out using the buttons at the top of the screen, or pan and zoom on the map directly. When you’ve found a location you’d like to use, simply click on the map to add a pushpin.
In fact, you can add as many pushpins as you’d like (there’s probably a limit, but I haven’t found it yet.)
What selecting a large number of locations allows you to do is emulate a walking or driving trip. Imagine you’re building an application that shows you the nearest fast food restaurants. By “pretending” to drive around town, you should be able to see your data in your application change as the locations change. To feed this data into your application, unclick the “Live” button at the top of the Location tool, and press the “Play” arrow button next to the “Fire every 1 sec” text.
You can change the duration, but the tool will move from point to point (in order), emulating a drive. If you accidentally add a pin to the map that was unintended, you can click the “X” next to any of the entries in the bottom left panel.
In the bottom right corner, you have the ability to Load previously recorded data. If you look at the top the tool, on the menu, you can clear all of your points, or save a set of points to be loaded later. This is where you can create individual sets of Location data to be used later during your testing.
This Location data tool should provide you with exactly what you need to create a compelling application that leverages lat/long data, whether it’s a jogging app, a social check-in style app, or even an app that provides driving directions.
The Screenshot Tool
The final tool you may have noticed in this Windows Phone Emulator add-on is the Screenshot tool. This is designed to make it easy for you to take screenshots of your application. This becomes especially important when you begin the process of submitting your application to the marketplace. You must have at least one screenshot of your app in order to submit, and it has to be 800 x 480 pixels in size. Instead of struggling with awkward screenshot tools that you may already be using, this tool will give you a perfectly sized screenshot of your application every time, regardless of the zoom level you use on the Emulator.
Unfortunately, it does not offer the ability to copy the image to your Windows Clipboard, but you can use the Save button to save it to a location on your machine. I recommend creating eight different screenshots for every one of your apps. You’re allowed to upload eight, so you should give your potential users as much visual information as you possibly can about what they are purchasing.
In short, the new tools in the Windows Phone Emulator are excellent for many purposes, but there are still many things your phone can do that these tools just don’t cover. For example, some phones now have a gyroscope, and all of the phones have a Compass that we also can’t emulate. Windows Phone 7.5 also brings us the advent of the Motion class, and we will cover that in detail later in this series.
For now, welcome to my next 31 Day adventure. Tomorrow in Day #2, we’re going to cover DeviceStatus, which gives us a wealth of information about our user’s device, including power source, physical keyboard availability, and more. See you then!
Opinions expressed by DZone contributors are their own.