Part 9: Overview of the Windows Phone 8 Emulator

Play Part 9: Overview of the Windows Phone 8 Emulator
Sign in to queue

Description

Source Code: https://aka.ms/absbeginnerdevwp8
PDF Version: https://aka.ms/absbeginnerdevwp8pdf

We've seen the Windows Phone Emulator at work in this series. It is a crucial component to developing apps for the Windows Phone platform, so I wanted to spend a little time becoming more familiar with it and point you in the right direction for more information.

Our game plan in this lesson ...

  1. We'll learn about what the Windows Phone Emulator really is, and how it supplies different versions for different deployment scenarios.
  2. We'll learn about the function of the Emulator, including keyboard shortcuts that emulate device buttons.
  3. We'll learn about the controls to resize, rotate and simulate the act of handling the virtual device as if it were a physical one, with accelerometer support, GPS support, and more.

 

1. What is the Windows Phone Emulator?

In a nutshell, the Windows Phone Emulator is a desktop application that simulates a Windows Phone device, and actually provides similar performance to a physical Windows Phone device. It provides a virtualized environment in which you can debug and test Windows Phone apps without a physical device—in fact like I said at the outset when installing the Windows Phone 8 API, it's running Microsoft's Hyper-V. For a friendly introduction to Hyper-V on Windows 8, check out this blog post from the Windows 8 team:

Bringing Hyper-V to "Windows 8"
https://blogs.msdn.com/b/b8/archive/2011/09/07/bringing-hyper-v-to-windows-8.aspx

Now, while the Emulator is great for development and quick debugging sessions, before you publish your app to the Windows Phone Store, Microsoft recommends that you actually test your app on a real Windows Phone.

 

2. Choosing different versions of the Emulator for debugging

Up to now, when we clicked the Run / Debug button on Visual Studio's toolbar, we were running the Emulator in its default configuration ... something called WVGA 512MB:

 

Generic Episode Image

 

What does WVGA and 512MB really mean?

The 512MB indicates that we're running in a memory constrained environment ... The default emulator image in Visual Studio is Emulator WVGA 512MB, which emulates a memory-constrained Windows Phone 8 phone. So, for example, the Lumia 610 is an inexpensive entry level Windows Phone 8 device which sports only 256MB of RAM. By contrast, the Lumia 920 has 1 GB of RAM. On lower-RAM devices, having multiple apps running at the same time or creating a memory intensive app might cause performance problems. So, to be sure that your app will run well on lower-RAM devices you can test your app using a realistic Emulator image.

There are a number of great articles about RAM usage on MSDN ... let me point out the best starting point to learn more:

App performance considerations for Windows Phone
https://msdn.microsoft.com/en-us/library/windowsphone/develop/ff967560(v=vs.105).aspx

Optimizing Apps for Lower Cost Devices
http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/03/07/optimizing-apps-for-lower-cost-devices.aspx

What does "WVGA" as well as those other acronyms stand for?

The Emulator allows you to test your app on a unique emulator image for each of the screen resolutions supported by Windows Phone. This default selection encourages you to target the largest possible market for your Windows Phone 8 app.

  • WVGA (800 × 480)
  • WXGA (1280 × 768)
  • 720p (1280 × 720)

If you run the default, then go to the Settings app in the About button, you can see this confirmed:

 

Generic Episode Image

 

How does this translate into the actual phones on the market?

Lumia 920
Display size: 4.5 inch
Display resolution: WXGA (1280 x 768)

Lumia 820
Display size: 4.3 inch
Display resolution: WVGA (800 x 480)

Lumia 610
Display size: 3.7 ''
Display resolution - WVGA (800 x 480)

I realize by the time you watch this there may be newer phone models. The point is that you should be aware of the fact that you'll need to support different screen resolutions and memory constraints. Like I talked about in the lesson on Layout using XAML, you will want to eliminate specific pixel sizes for layout (except for margins). Choosing from the different Emulator sizes, you can make sure you're on the right track.

3. Working with the Phone Emulator's special features

I'll not spend a lot of time on the phone's basic navigation. A lot of this you'll pick up by using the Emulator throughout the series if you don't already have a physical phone in your possession. Essentially, you'll have an almost identical experience, complete with the Start and Apps page, search, web browsing, clock, battery, etc.:

Generic Episode Image

 

You have the same hardware buttons on the bottom of the Emulator as you would have on a Windows Phone:

 

Generic Episode Image

 

Note that you'll be missing the buttons on the side of the phone. For example, my Lumia 920 has three buttons on the side—a volume up and down, a power button, and a camera button. These can be access in the Emulator with keyboard function keys.

There's a list of keyboard mappings here:

https://msdn.microsoft.com/en-us/library/windowsphone/develop/ff754352(v=vs.105).aspx#BKMK_KeyboardMapping

  • F6 - Camera button half-way
  • F7 - Camera button
  • F9 - F10 raise and lower the volume
  • F11 - plays / pauses audio ... it simulates an in-line headphone button that pauses music and answers incoming phone calls. If you double-tap the button, it'll skip to the next audio track on your playlist or album
  • F12 - Power button / lock screen
  • F1 - Back button
  • F2 - Windows key
  • F3 - Search button

Let's work with the Emulator's keyboard ... F3 to Search:

Generic Episode Image

 

You'll see the phone's keyboard appear. I can use my mouse to simulate tapping the keys. Most of the time during development, that's a pain. I would rather use my computer's keyboard.

PAGE DOWN button - When a textbox is the target input, PAGE DOWN disables the virtualized "hardware" keyboard down, and you can use your physical keyboard for input.

PAGE UP button - When a textbox is the target input, PAGE UP enables the virtualized "hardware" keyboard.
PAUSE/BREAK button - Toggles the keyboard, so you could just use that all the time.

As you can see, I typed in the search phrase "selfridge chicago", looking for articles or a Wikipedia article on one of Chicago's most famous sons, Harry Selfridge who founded the retail store Selfridges of London, and is the subject of a popular TV show on the BBC.

When I click the "Go" keyboard:

 

Generic Episode Image

 

The Bing search works in the Emulator just as it would on a physical device, asking for permission to use your location in case it influences the search results. For example, if I were in London, Bing might show me a map of Selfridges near me. However, since I'm in the USA Bing will deliver different results. I'll show you how the Emulator determines its location in just a moment:

 

Generic Episode Image

 

In addition to the "virtualized" phone on screen, there's a floating menu off to the right. A little experimentation will reveal the functions of the first six buttons, in order:

  1. Shuts down the emulator
  2. Minimizes the emulator
  3. Rotates the emulator 90 degrees counter clockwise
  4. Rotates the emulator 90 degrees clockwise
  5. Expands the emulator to the largest size that can fit comfortably on your computer screen
  6. Brings up the zoom dialog
    Generic Episode Image
  7. Opens up the additional tools dialog.  There are four tabs on the Additional Tools dialog. The first is the Accelerometer which can be used to test apps that utilize the accelerometer sensor:
    Generic Episode Image

 

  1. You can change the center point of the phone to change its position in 3D space by clicking and dragging the orange dot in the circle.
  2. You can change the Orientation to one of the presets.
  3. You can play recorded data, like a "shake" motion.

For more information about the Emulator and the Accelerometer sensor in the Windows Phone SDK, a good starting spot would be this article:

How to test apps that use the accelerometer for Windows Phone
https://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202936(v=vs.105).aspx

The next tab is the Location tab which allows you to set the current location of the phone. So, even though I'm sitting in Dallas, Texas, I can act like I'm testing my phone in Chicago or any other place in the world. To do this:

Generic Episode Image

 

  1. Perform a search for a particular location, like "Chicago, IL".
  2. Right-click the map to create a pin.
  3. I'll verify the exact location in the list of pins marked by their latitude and longitude.

Now, I can go to the Windows Phone Emulator's Map app to see the map zoom to that location. We'll rely on this technique later in this series when we create our AroundMe app.

The third tab is for creating Screenshots, which can be helpful when you're creating documentation or bug reports:

 

Generic Episode Image

 

And the final tab is the Network tab. There's not a lot you can do other than see the IP address of the phone on the network:

 

Generic Episode Image

 

In addition to the Emulator itself, Visual Studio has some tooling that can affect how the XAML designer displays the phone (orientation, theme and color, chrome, etc.):

 

Generic Episode Image

 

There's also a Simulation Dashboard that allows you to validate your Windows Phone apps in various real life conditions.

 

Generic Episode Image

 

The Simulation Dashboard gives you the ability to simulate different network conditions, trigger reminders, and check how your app will perform under a locked screen:

 

Generic Episode Image

 

You have so many ways to test and monitor your app during development time so you gain some confidence in how it will perform when you distribute it on the Store.

Recap

The last tip I would give about the emulator is that it's ok to just leave it up and running during development. There's no need to shut it down. When you launch and re-launch your app in debug mode from Visual Studio, part of that process is deploying the latest version of the app to the phone. It's time consuming to relaunch the Emulator each time, and Visual Studio will connect to an existing Emulator instance when it needs to.

So to recap, the Emulator is a great tool that allows you to quickly deploy your app during development to a virtualized Windows Phone. We looked at how to test different device screen sizes and memory constraints, how to manipulate the emulator to test for rotation and motion, how to make the phone think it is located geographically in a specific place, and much more. We'll use these skills extensively throughout this series.

Embed

Download

The Discussion

  • User profile image
    Shaikh Ejaz

    What if I dont have windows 8 as Operating System?
    Can I use any desktop emulator to test my app.?

  • User profile image
    BobTabor

    @Shaikh Ejaz: Possibly, but I can't recommend it.  You could try creating a Virtual Machine and running Windows 8 inside of that provided it meets all the other criteria.  However, again, can't recommend it.  Try at your own risk.

  • User profile image
    Shenzhongwei

    In 'the Lumia 610 is an inexpensive entry level Windows Phone 8 device which sports only 256MB of RAM', sports might be supports.

  • User profile image
    Clint

    @Shenzhongwei: in the US, that is "sports" slang for "has".

  • User profile image
    Clint

    @Shenzhongwei: and actually this is a mistake here.  Lumia 610 is an entry level WP 7.5 phone, WP 8 phones sport a minimum of 512 MB of RAM.  An example of this is a Lumia 520 or 620.

  • User profile image
    Rida221

    Hi there! I am unable to access the internet on my emulator please can you point out how I can do that?

  • User profile image
    Clint

    @Rida221:  Try this, delete the virtual network switches and relaunch the emulator.  (Control Panel\Network and Internet\Network Connections), you'll see stuff with "vEthernet"

  • User profile image
    stevewp8dev

    Thanks Bob, for the thorough runthrough.  The tip about using your hardware keyboard is great.

    Question about leaving emulator running while coding.  Is there a setting somewhere I need to adjust, to tell Visual Studio not to block the code editing ?  I literally can't type anything in the code while my emulator is running.

    I have a Win 8 Pro, SLAT supported, etc..PC  (of course, or the emulator wouldn't run). And working on a WP8 app.  Using Visual Studio 2012 Express.

  • User profile image
    Clint
    @stevewp8dev: betting your app is still running. Hit the stop button in the toolbar. Vs is running your app with the debugger attached so you can do break points.
  • User profile image
    stevewp8dev

    Oh gosh. yeah that simple thing was it.    Thanks Clint!

  • User profile image
    Ahd

    it is possible to emulate my WP7 app on WP8 device like lumia 820 ?

  • User profile image
    BobTabor

    @Ahd: I'm not sure.  Never tried that.  It would be easy enough to try (and quickly fail ... if it doesn't work).  Good luck!

  • User profile image
    Clint

    @Ahd: it can.  look at the Coding4Fun Toolkit.  I have both a wp7 and wp8 testing application in it.  WP7 applications are fully backwards compatible with WP8

  • User profile image
    WSims

    A couple of questions if I may,

    I too have the 920, My windows 8 desktop is not the pro version so I use my phone as the debug device, Is there a risk of bricking my 920 doing so?

    Also if I do upgrade to the pro version, and my LapTop being a touch screen will this allow me to use the emulator in the same manner as the windows phone tap, hold, swipe, long hold and other gestures that are part of the windows phone 8 operating system?

    and sorry but last

    Does the emulator update to the latest version of current Windows Phone 8 O.S, for example I updated my phone not long ago to Lumia Amber which made for some pretty drastic changes in available behaviors such as going from only having something like a 10 minute screen timeout to always on.

    This is most likely the reason why it is suggested that an app be tested on a real device and not just an emulator but I wondered just how updated the EM was compared to the current version of windows phone 8 operating software?

    But I have to admit my biggest concern is bricking my phone My wife would KILL me if I destroyed it.!

  • User profile image
    Clint

    @WSims

    1. You don't need Pro if you are deploying directly to a phone.  Pro edition gives Hyper-V which allows virtualization tech that the emulator runs in.
    2. For multi-touch, yup, it will.  I just verified on my Lenovo X1
    3. you dev unlock your phone and just allows you to sideload applications, it won't mess it up.  I've been doing this on a ton of different window phones for years.  Smiley
  • User profile image
    Mahesh

    I am not able to access internet from windows phone 8 emulator , I tried all possible ways as shown in this link http://stackoverflow.com/questions/13159947/windows-phone-8-emulator-cant-connect-to-the-internet

  • User profile image
    Aman

    Hi Bob,

    Just wanted to know -- my computer's hardware doesn't support the emulator, so I only use my HTC 8X to test on. Can I skip this video and not miss anything important?

  • User profile image
    BobTabor

    @Aman: Just scan the text / picture above to make sure there's nothing you want to see, but yes, I think you could safely skip this.

  • User profile image
    ahsan123

    can i watch next tutorials cuzz i have no  physical windows phone device !!!

  • User profile image
    BobTabor

    @ahsan123: Yes, it is possible to follow this course with just the phone.  It certainly will not be as convenient, but it is an option.

  • User profile image
    Sam Solomon Prabu S D

    I'm getting problem in downloading High Quality MP4 video. I downloaded all other videos except this one. Kindly help me to solve this problem. Thanks in advance.

  • User profile image
    dagwoodbenn​ett

    What are the limitations of the emulator in terms of the API set for WP8? For example I have been trying to write an app that uses the Microsoft.Phone.Net.NetworkInformation namespace classes (DeviceNetworkInformation, NetworkInterface, NetworkInterfaceInfo, etc) to try to log info on what network I am using and the capabilities of the network (bandwidth, speed, latency, connection type, etc) but I'm finding these don't appear to work in the emulator.... Is there documentation that covers this (if yes, then a link would be great)... thanks!

  • User profile image
    gurudubey

    sir my emulator is not loading OS pleas sir will you point me in right direction so that I can sort it out.......

  • User profile image
    huunghi

    please help me. My virtual machine is not connected to wifi. using Visual Studio 2013.

  • User profile image
    jmjob

    I am concern about my pc memory size needed. I just bought a new ultrabook especially for developing and it has "only" 4GB memory. The emulator does not open because it says that the memory is not enough. How many minimal memory this emulator will be able to run?

    Now I run all by the device.

    BTW Congratulation your tutorial is well done and very interesting. I like the text following the video (below).

  • User profile image
    DaleL487

    Love the tutorials, find them so easy to follow (Currently doing the most recent C# Fundamentals for Beginners, but want to get to this one ASAP.)

    Would you recommend the emulator or an actual WP8 device for testing the apps?

  • User profile image
    Banny

    @DaleL487: Yes Dale487, you are right. This emulator very good for testing the apps.

Add Your 2 Cents