380 likes | 590 Views
Windows Mobile Application Development with Microsoft Visual Studio 2008. Maarten Struys Windows Mobile Evangelist Alten -PTS Session Code : MOB201-SUN. Agenda. Introduction Creating a Windows Mobile Application Testing Windows Mobile Applications Data on the Device
E N D
Windows Mobile Application Development with Microsoft Visual Studio 2008 Maarten Struys Windows Mobile Evangelist Alten-PTS Session Code: MOB201-SUN
Agenda • Introduction • Creating a Windows Mobile Application • Testing Windows Mobile Applications • Data on the Device • Making use of Device Capabilities • Battery Friendly Development • Conclusion
IntroductionDeveloping Windows Mobile Applications • Use the same development tools as desktop developers • There are a few challenges • Slower processors • Battery powered devices • User Interface restrictions • Device Security • Application installation and execution • Encryption of data, devices can ‘easily’ be lost
IntroductionWindows Mobile • One brand name for a wide variety of devices • Windows Mobile 6 Standard (Smart Phone) • Windows Mobile 6 Professional (Pocket PC) • Software Development Tools • Visual Studio 2005 Professional or better • Support for Native and Managed applications • .NET CF 1.0 and .NET CF 2.0 support • Visual Studio 2008 Professional or better • .NET CF 3.5 and .NET CF 2.0 support
IntroductionInstalling the Windows Mobile 6 SDKs • To develop applications for WM 6 devices you need to install the WM 6 SDK’s • Separate downloads for Standard and Professional • Integrate seamlessly in Visual Studio 2008 • You can also download Windows Mobile 6.1 emulator images to target newer Devices • To develop for Windows Mobile 6.5 also install the Windows Mobile 6.5 DTKs
IntroductionUsing the Development Tools • Developer experience identical for Desktop and Windows Mobile applications • Fewer UI controls available • Fewer API’s available • Target the .NET Compact Framework • Highly compatible subset of the full .NET Framework • Target Platform differs from Development Platform
Developing ApplicationsChallenges • Dealing with different devices, different screen sizes and different hardware • Creating effective user interfaces • Synchronizing data with desktops / servers • Network connections • Battery life
Targeting Different DevicesDevice Emulator is your Friend • Why use the emulator to begin with? • Allows targeting a large range of devices without having access to physical devices • Allows testing cellular connections without needing a costly physical connection • Allows easy testing of different security scenarios
demo Creating your first Windows Mobile AppHello World in C++, C# and Visual Basic.NET
Testing your ApplicationUnit Testing for Devices • Unit Testing is a procedure used to validate that individual pieces of source code are working properly • A Unit is the smallest testable part of code • In C# and VB.NET methods inside classes • Calling methods with different parameters and examining return values • Unit Tests are typically written by the developer
Testing your ApplicationCreating Unit Tests • Unit Tests can be generated automatically or created manually • The latter makes sense for Test Driven Development • They will exist in a separate test project • You can target both the .NET CF 2.0 and the .NET CF 3.5 • Need at least Visual Studio 2008 Professional
Testing your ApplicationExecuting and Retrieving Results • Unit Tests are started on the development machine but will execute on the device • Test results are displayed inside Visual Studio • Tests can be executed from inside Visual Studio 2008 or from a Command Prompt making use of mstest.exe
demo Creating and Running Device Unit Tests
Storing Data on the DevicePlanning ahead is Important • No application exists without data • Consider your data needs during design • Using unstructured data? • Providing my own data store functionality? • Using a real database on the device? • How about synchronization to a back-end server?
Storing Data on the DeviceTwo ‘popular’ approaches • Using XML files • True platform independence • Good support in managed code with DataSet.ReadXml and DataSet.WriteXml • Overhead because of XML • Using SQL Server 2005 CE • Great performance • Use existing SQL Server skills • Design the database on the desktop • Needs the .NET Compact Framework 2.0 • Does not run on every device
Storing Data on the DeviceTyped DataSet • In memory representation of a database • Manipulate data as a small relational database • Save or load contents to XML • Save or load contents to SQL Server Mobile or from remote server • Receive populated datasets from Web Service • Pass datasets to Web Service
Storing Data on the DeviceSqlCeResultSet • Provides direct connectivity to the SQL Server Mobile Edition database • Supports forward and backward scrolling • Supports updates • Supports databinding
Storing Data on the DeviceSynchronization with Backend Servers • Microsoft SQL Server 2005 / 2008(Express Editions supported) • Visual Studio 2008 (SP1) • Microsoft SQL Server Compact 3.5 (SP1) • Microsoft Synchronization Services for ADO.NET 1.0
demo Using SQL Server CE
Device CapabilitiesUsing already installed functionality • Windows Mobile Devices come with a lot of software already pre-installed • Pocket Outlook • Office Mobile • Internet Explorer • Windows Media Player • The Windows Mobile 6 Managed SDK exposes some of this functionality to application developers
Device CapabilitiesManaged APIs to access Pocket Outlook • Wraps POOM • Using and managing Personal Information Manager items inside your own application • Contacts, Appointments, and Tasks • E-mail, SMS and MMS • Consistent interface to access information
Device CapabilitiesThe Gateway to your Device • Look at Microsoft.WindowsMobile namespace • Collection of classes, enumerations, and delegates • Ships as part of the Windows Mobile 6.0 SDK • Provide functionality for managed developers • Application and platform level APIs • More control of the device in managed code • Supplement existing libraries • No part of the.NET Compact Framework
Device CapabilitiesMaking Phone Calls • Two lines of code to make a phone call Phone phone = new Phone(); phone.Talk(“123-456-7890”);
demo Making use of Device Capabilities
Battery Friendly DevelopmentIntroduction • Windows Mobile devices are very powerful • However, they are useless with empty batteries • Decreasing the used power means increasing the battery life • Don’t do anything unless it is absolutely necessary!
Battery Friendly DevelopmentBe a Good Citizen (1) • When interacting with the user, an application is free to consume as much as necessary • Reducing the “necessary” amount is what performance optimization is all about • In the background, it should consume very little memory, and ZERO battery power • If all applications behave correctly, user satisfaction increases for each application and for Windows Mobile as a whole
Battery Friendly DevelopmentBe a Good Citizen (2) • Don’t use the processor • Disable radio’s when not needed • Absolutely don’t use the processor when the application is in the background • Don’t use polling at any time • Limit application functionality when the battery level is low • Don’t keep the backlight on
Battery Friendly DevelopmentDevice Differences • Windows Mobile Standard • Device can either be on or off • When off nothing works • Windows Mobile Professional • Device can be in suspend mode (sleep) • Separate state between on and suspend, called unattended • When the device seems off it is probably asleep
demo Be Friendly to the Device Battery
Session Summary (1) • Developing applications for Windows Mobile Devices is as easy as developing desktop applications • However …. • You have to deal with different form factors • You should develop battery friendly applications • Install the Windows Mobile 6 SDK’s • Make use of Unit Testing and the emulator to test your apps
Session Summary (2) • SQL Server CE is a great database to store data locally and to synchronize with servers • Re-use existing functionality on the device • Access device hardware through the managed API’s that are part of the Windows Mobile SDKs • Take a look at the sample code in the SDKs to get started yourself
Required Slide Speakers, TechEd 2009 is not producing a DVD. Please announce that attendees can access session recordings at TechEd Online. Resources • www.microsoft.com/teched Sessions On-Demand & Community • www.microsoft.com/learning • Microsoft Certification & Training Resources • http://microsoft.com/technet • Resources for IT Professionals • http://microsoft.com/msdn Resources for Developers
Required Slide Speakers, please list the Breakout Sessions, TLC Interactive Theaters and Labs that are related to your session. Related Content MOB01-IS - Windows Mobile Tips and Tricks for Developers MOB03-IS - Performance Optimization and Power Management for Windows Mobile Devices MOB05-IS - Come Meet the Windows Mobile Team! MOB307 Introducing the patterns & practices Mobile Application Blocks
Complete an evaluation on CommNet and enter to win an Xbox 360 Elite!
Required Slide © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.