Windows Phone Guide for Android Application Developers Table of Content



Download 0.57 Mb.
Page7/15
Date04.05.2017
Size0.57 Mb.
#17233
1   2   3   4   5   6   7   8   9   10   ...   15

Building Application


Similar to Eclipse, Visual Studio Express 2012 for Windows Phone allows you to build a Visual Studio solution on demand. Further, each project that is part of the solution can be built separately.

Visual Studio uses an XML based, declarative build system called MSBuild which can be compared to Ant or Nant. Builds can be invoked interactively or via a command line for batch processing. This system is flexible and allows you to build a specific target either as a debug build or as a release build.




Tool for Testing


Windows Phone 8 developer tools include an emulator that can be used effectively for testing applications. It provides features that are comparable to the Android simulator included in the developer tools.

The Windows Phone 8 emulator provides a virtualized environment in which you can deploy, debug and test applications. The Windows Phone Emulator is designed to provide comparable performance to an actual device and meets the peripheral specifications required for application development. As you can see below, the emulator allows emulation of accelerometer as well as device location. It can be invoked from Visual Studio to load an application package [.xap] within the emulator.




Debugging


Visual Studio Express 2012 for Windows Phone includes a very powerful symbolic debugger that can be used with the Windows Phone 8 emulator or with a remote device. Once the application breaks into the debugger, the developer can view the variables in the application and control the execution.

Let us look at the debugger in action. Press F5 to launch the application again. Type “napkins” in the textbox and click Add Napkins is added to our list.



Now add, “milk” but find that “napkins” gets removed - not something we expected.

In Visual Studio, click in the light blue area to the left of the “string tStr = txtItem.Text;” line in the code window. This will insert a breakpoint at that line.

Enter “milk” and click Add. When the application breaks into the debugger, use “Step over” or (f10) to enter the outer if block. Hover over initialized variable in the code as shown and Visual Studio shows its value as false something we did not expect Step through to find that the execution enters the inner if and resets txtList.Text to blank again – therein lies our bug. After adding first item to the list, we should have set the value of initialized to true.



Fix the bug by adding, initialized = true; in the inner if statement and restart the application.

You can inspect any variable, its type, its fields and properties while debugging. For example, hover over txtList and click + to inspect various properties of txtList.

You can set a “watch” on certain variables to inspect them continuously. Right click txtList, followed by Add Watch. The watch window will show the variable txtList througout.



In the debugger, the developer can use the Visual Studio ‘immediate mode’ where one can write managed code instructions to modify or view the variables or execute some code to help with debugging.



Update the code and re-launch the application. Test it by adding couple of items to the shopping list.



Similar to Java applications using Eclipse with ADT, the Windows Phone 8 application debugging is done entirely at the application source code level. Overall, you will find that, with the power of Visual Studio and C#, debugging a Windows Phone 8 application is very easy whether you are running the application in the emulator or an actual device.

In addition to the above debug facilities, the .NET Framework includes two specific classes, Debug and Trace, that make it easy to write run-time debug messages to the output window. C# also supports an assert statement, which is evaluated at run time. If the statement evaluates to true, nothing happens, but if the statement returns false, the program breaks into a debugger.

Summary


In this chapter we looked at the Windows Phone Developer Toolset. The tool set includes rich tools that are designed to support every step in the entire application development lifecycle. The design, development, and testing tools are amenable to the existing Android team roles and processes. The tight integration between the Windows Phone 8 development tools helps you to streamline the design, develop the workflow, and test the workflow. These tools provide end-to-end functionality and are highly customizable, with the power to make your team quickly productive.

Chapter 4: An Introduction to C# programming for Java developers


In the previous chapter, we looked at the user interface guidelines for Windows Phone 8 applications. We will now dive deeper into what it takes to implement a Windows Phone 8 application.

In this chapter, we will look at the various C# features that map to the most common Java features. We will provide code snippets which will ease the transition into C# code. We will point to the key C# features that help you write safe code and enhance productivity.




Download 0.57 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   10   ...   15




The database is protected by copyright ©ininet.org 2024
send message

    Main page