An end-to-end experience of Windows Phone 7 development (Part 1)

47

description

DevDays 2011 South Africa - An end-to-end experience of Windows Phone 7 development (Part 1)

Transcript of An end-to-end experience of Windows Phone 7 development (Part 1)

Page 1: An end-to-end experience of Windows Phone 7 development (Part 1)
Page 2: An end-to-end experience of Windows Phone 7 development (Part 1)

Rudi Groblerhttp://www.rudigrobler.net@rudigrobler

An end-to-end experience of Windows Phone 7 development

TRACK: NEXT GENERATION

Page 3: An end-to-end experience of Windows Phone 7 development (Part 1)

agenda

Orientation

Tombstoning

ApplicationBar

Threading

Location

Performance

Page 4: An end-to-end experience of Windows Phone 7 development (Part 1)

orientation support

PhoneApplicationPage.SupportedOrientations property states what orientations the page supports

PortraitLandscapePortraitOrLandscape

If set to PortraitOrLandscape, page will re-orientate itself automatically when the user rotates the phoneYou cannot force a page to re-orientate in codeYou can force a page to always use a specific orientation by setting the SupportedOrientations property to the value you required

Page 5: An end-to-end experience of Windows Phone 7 development (Part 1)

Orientation using VSM

demo

Page 6: An end-to-end experience of Windows Phone 7 development (Part 1)

orientation + SIP

SIP takes up more space landscape than portrait

vs

Page 7: An end-to-end experience of Windows Phone 7 development (Part 1)

system tray and application bar

System TraySystem owned indicator area that display system-level status informationApps can show/hide

Application BarArea where applications can display buttons for the most common tasksCan display pop-up menu for less common tasks

Page 8: An end-to-end experience of Windows Phone 7 development (Part 1)

application bar

Use the ApplicationBar instead of creating your own menu systemUp to 4 buttons plus optional menu

Swipe up the bar to bring up the menuAll buttons must specify Text property as well as IconUrl (Changed in Beta)

Don’t fill all 4 slots if not neededUse white foreground on transparent background for icons

System will colorize button according to users selected theme

Page 9: An end-to-end experience of Windows Phone 7 development (Part 1)

Application bar

Page 10: An end-to-end experience of Windows Phone 7 development (Part 1)

application bar

Page scoped – Search, etcNot for item specific actions like save/delete, rather use the ContextMenuAbove SIP

Page 11: An end-to-end experience of Windows Phone 7 development (Part 1)

basic application lifecycle

Not Running

Launching

Running

Closing

Page 12: An end-to-end experience of Windows Phone 7 development (Part 1)

Low Battery

a world of interruptions

Phone Calls

Lock Screen

Text Message

Reminders

Application Switch

Page 13: An end-to-end experience of Windows Phone 7 development (Part 1)

Application lifecycle – the problem

Page 14: An end-to-end experience of Windows Phone 7 development (Part 1)

moved to background

Running

Deactivate

Tombstoned

Activate

Fast switching a.k.a. dormant

Dormant

Tombstoned

Save state

Restore state

Page 15: An end-to-end experience of Windows Phone 7 development (Part 1)

application management

Windows Phone execution model is designed to provide end users with a fast, responsive experience

Only one application can run at a timeSystem terminates application when user navigates away

Application is Tombstoned when user navigates awaySystem saves state information then terminates you applicationWhen user navigates back to the application system restarts the application and passes state information back

Developer must write code to respond to lifecycle eventsSave and restore stateMaintain illusion that the application is running continuously

Check if tombstoned (IsAppInstancePreserved)

Page 16: An end-to-end experience of Windows Phone 7 development (Part 1)

lifecycle events - application

Application_LaunchingWhen the application is launching (from start)Not fired when the application is reactivated

Application_ActivatedWhen application is activated (brought to foreground)Not fired when the application is first launched

Application_DeactivatedWhen the application is deactivated (sent to background)Not fired when the application is closing

Application_ClosingWhen the application is closing (user hit back)Not fired when the application is deactivated

Page 17: An end-to-end experience of Windows Phone 7 development (Part 1)

lifecycle events - page

OnNavigateToOnNavigateFrom

Page 18: An end-to-end experience of Windows Phone 7 development (Part 1)

Application lifecycle – the solution

Page 19: An end-to-end experience of Windows Phone 7 development (Part 1)

optimizing tombstoning (1)

Know what to savePivot.SelectedItem

TIP: Set in Loaded and NOT NavigateToPanorama.DefaultItemScrollViewer position (use ScrollPositionHelper)TextBox.TextViewModel

Where to savePhoneApplicationService.Current.State[]PhoneApplicationPage.State[]Cache to IsolatedStorage

When to saveApplication life cycle eventsPage-level OnNavigateFrom/OnNavigateTo

Do not save state on back navigation

Page 20: An end-to-end experience of Windows Phone 7 development (Part 1)

optimizing tombstoning (2)

Optimize your storage formatsDataContractSerializerJSON.NET (MS implementation is VERY slow)XMLBinary (More work but VERY fast)

MUST rehydrate in less than 10 secondsDefer loading when possible

Page 21: An end-to-end experience of Windows Phone 7 development (Part 1)

optimizing tombstoning (3)

Release resourcesCamera, Video, Location, Sensor, etc

On rehydrate/activate, remember GPS warm-up time

Framework will stop audio, sensors, networking, sockets, MediaElement & camera

Page 22: An end-to-end experience of Windows Phone 7 development (Part 1)

Test your tombstoning!!!

Page 23: An end-to-end experience of Windows Phone 7 development (Part 1)

phone threading model

•Primitive animations•Composite onto back bufferCompositor

•Rasterize•Binding•Layout•TouchUI•Dispatch•Networking•Parsing

Background

Touch thread

Page 24: An end-to-end experience of Windows Phone 7 development (Part 1)

PerformanceProgressBar

“The ProgressBar template for Silverlight that is built into the Windows Phone today has a negative performance cost in ‘indeterminate’ mode (the animating dots that often indicate loading during an operation of

unknown time). The control is also known as ‘progress indicator’ according to the UX guidelines for the phone.”

Use PerformanceProgressBar (Available in the Silverlight Toolkit for Windows Phone)Read more on Jeff Wilcox’s blog:

http://bit.ly/PerformanceProgressBar

ProgressIndicator

Page 25: An end-to-end experience of Windows Phone 7 development (Part 1)

LowProfileImageLoader

“LowProfileImageLoader is meant to address a very specific scenario: loading lots of images from the web at

the same time.”

Read more on David Anson’s blog:http://bit.ly/LowProfileImageLoader

Image decoding on background thread

Page 26: An end-to-end experience of Windows Phone 7 development (Part 1)

Location

Location services

WiFi

+ Accuracy- Power- Speed- Indoors- Accuracy

+ Power+ Speed- Wilderness

+/- Accuracy+/- Power+/- Speed+/- Urban areas

Cell towers

Page 27: An end-to-end experience of Windows Phone 7 development (Part 1)

Location

Page 28: An end-to-end experience of Windows Phone 7 development (Part 1)

GeoCoordinateWatcher

Warm it upSingletonCan be disabled

Page 29: An end-to-end experience of Windows Phone 7 development (Part 1)

persistence

All IO is restricted to Isolated StorageCreate files Manage Settings

Ideal for caching dataCheck out WP7Contrib and AgFx

Isolated Storage based Relational DBsSterlingSQLite

Structured storage

Page 30: An end-to-end experience of Windows Phone 7 development (Part 1)

performance counters

Application.Current.Host.Settings.EnableFrameRateCounter = true;

MetricsCounter Ideal Min Best Experience Theoretical Max

Compositor Thread 30 fps 60 fps 120 fps

UI Thread 15 fps > 15 fps 120 fps

Screen Fill Rate 1.0 <= 2.0 N/A

Page 31: An end-to-end experience of Windows Phone 7 development (Part 1)

push notifications

Server-initiated communicationEnable key background scenariosPreserves battery life and user experiencePrevents polling for updates

Page 32: An end-to-end experience of Windows Phone 7 development (Part 1)

types of notifications

Toast

Tile

Deep toast

Page 33: An end-to-end experience of Windows Phone 7 development (Part 1)

Push Notification Architecture

HTTP Post to URI with payload

Push URI request/response

Push enabled application

Push client service

Push client/server negotiation2

Push URI to Cloud Service

4

5

Push notification to device6

Cloud Service

MPNS

Windows Phone 7

13

Page 34: An end-to-end experience of Windows Phone 7 development (Part 1)

Scenarios/Popular Applications

Weather TileWarning Toast

Weather Apps

Turn TileMove Toast

Chess by Post

Unread TileDirect Toast

Beezz

Link TileLink Toast

Send to WP7

Traffic Tile

Seattle Traffic Map

Turn TileMove Toast

AlphaJax

There are hundreds and hundreds of Push apps in Marketplace!

Page 35: An end-to-end experience of Windows Phone 7 development (Part 1)

Windows Push Notification Server Side Helper Library

“The library provides an easy way for sending all three kinds of push notification messages currently supported by Microsoft Push Notification Services (MPNS):

Tile, Toast, and Raw. Our main goal here is to extract any complexity for sending push notification (PN) messages from your website (or web service) to a

Windows Phone. This library helps developers to send push messages using only a few lines of code.”

Read more on the Windows Phone Developer blog:http://bit.ly/PushNotificationHelper

Page 36: An end-to-end experience of Windows Phone 7 development (Part 1)

don’t re-invent the wheel

Control ToolkitsPhoneyToolsCoding4Fun ToolkitSilverlight Toolkit for Windows PhoneWP7Contrib

MVVM ToolkitsMVVM LightCaliburn.Micro

DatabasesSterlingSQLiteAgFx

Page 37: An end-to-end experience of Windows Phone 7 development (Part 1)

NuGet

Page 38: An end-to-end experience of Windows Phone 7 development (Part 1)

text input

TextBox integrates with the software keyboardSoftware keyboard supports input scoping

Key InputScopes: EmailNameOrAddressTextUrlNumberTimeTelephoneNumber

PasswordBox has a 1 second delay

Text Text Revolution: A Game that Improves Text Entry on Mobile Touchscreen Keyboards

Page 39: An end-to-end experience of Windows Phone 7 development (Part 1)

Text input

Page 40: An end-to-end experience of Windows Phone 7 development (Part 1)

memory constraints

Do not use more than 90mb of RAMUse Coding4Fun Toolkit MemoryCounter

+/- 30% reduction in working set

Page 41: An end-to-end experience of Windows Phone 7 development (Part 1)

Certification checklist

No network, no problem?<90MB?Theme aware?Handles exceptions?Back button works as expected?User consent dialogs & settings

Page 42: An end-to-end experience of Windows Phone 7 development (Part 1)

Monitor your application

Add a “Send Feedback” buttonStore crash data and ask user to email itAnalytics

Page 43: An end-to-end experience of Windows Phone 7 development (Part 1)

Slides, demos, etc…

@rudigrobler

http://www.rudigrobler.net

questions

Page 44: An end-to-end experience of Windows Phone 7 development (Part 1)

Don’t forget the Xbox Kinect show-down

after sessions this evening!

Page 45: An end-to-end experience of Windows Phone 7 development (Part 1)

DevDays 2011 Sponsors

PLATINUM SPONSORwww.bbd.co.za

SILVER SPONSORwww.dvt.co.za

SILVER SPONSORwww.ctutraining.co.za

Page 46: An end-to-end experience of Windows Phone 7 development (Part 1)

Keep in Touch

facebook.com/msdevsa

@msdevsa

http://blogs.msdn.com/southafrica

Page 47: An end-to-end experience of Windows Phone 7 development (Part 1)

© 2008 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.