Liven up your WP7 Apps with sweet “Mango” sauce Jaime Rodriguez Microsoft @jaimerodriguez http://blogs.msdn.com/jaimer jaimer@microsoft.com
A to-do app….
Tidy DEMO
http://bit.ly/WP7AppsDoMore “Apps are smarter on Windows Phone.. Where the same apps Do more” Joe Belfiore, VP
Agenda
Local database SQL CE 4 Sandboxed LINQ to SQL Your App Custom Data Context App Objects System.Data.Linq Identity Management Change Tracking Update Processing Object Materialization Microsoft.Phone.Data.Internal Core ADO.NET (System.Data) SQLCE ADO.NET Provider (System.Data.SqlServerCe) SQL CE DB
SQL CE CODE WALK-THROUGH
LINQ To SQL Mapping Attributes Atrribute Example Description TableAttribute [Table] Designates a class as an entity class that is associated with a database table. ColumnAttribute [Column(IsPrimaryKey = true)] Associates a class with a column in a database table. IsPrimaryKey specifies the primary key, for which an index is created. IndexAttribute [Index(Name="LastNameIndex", Columns="LastName")] Written at the table level, designates the column of a database table as a secondary index. AssociationAttribute [Association(Storage="ThisEntityRefName", ThisKey="ThisEntityID", OtherKey="TargetEntityID")] Designates a property to represent an association, such as a foreign key to primary key association.
Lessons and tips MS recommends code first approach SQL Metal works too Design object model Apply Attributes SQL Metal works too Leverage background threads Keep changes small (aka save often) Let SQL do the work
Multi-tasking design principles Delightful and Responsive UX Battery Friendly Health Never Regret App Install Network Conscience UX Integrated Feel Hardened Services
Multi-tasking Options Background Transfer Service Background Audio Background Agents Periodic On Idle Alarms and Reminders
Background Transfer Service Start in foreground, complete in background, even if app is closed Queue (of 5) persists across reboots Single service for many apps, FIFO Download ~20 MB ( > over Wi-Fi) Upload Size ~4 MB (limit to come) Transfers to Isolated Storage Queue size limit = 5 Queue APIs (Add, Remove, Query status)
Background Transfer CODE WALK-THROUGH
Notifications Time-based, on-phone notifications Supports Alerts & Reminders Persist across reboots Adheres to user settings Consistent with phone UX
Alarms vs Reminders? Alarms Reminders Modal Rich information Snooze and Dismiss Sound customization No app invocation No stacking Rich information Integrates with other reminders Snooze and Dismiss Launch app Follows the phones global settings
Reminders CODE WALK-THROUGH
Live Tile improvements Local Tile APIs Full control of ALL properties Multiple tiles per app Create,Update/Delete/Query Launches direct to Uri Application Tile Launches main app experience Secondary Tile Launches world news page Secondary Tile Launches local news page
Live Tiles – Local Tile API (2) Back of tile updates Full control of all properties when your app is in the foreground or background Content, Title, Background Flips from front to back at random interval Smart logic to make flips asynchronous Title Content Background Content string is bigger
Live tiles CODE WALK-THROUGH
Generic Agents Periodic Agents On Idle Agents Occurrence Occurrence Every 30 min Duration ~15 seconds Constraints <= 5 MB Memory <=10% CPU On Idle Agents Occurrence External power, non-cell network Duration 10 minutes Constraints <= 5MB Memory All of this is requirements can change before RTM, but should not change too much
Background Agent Functionality Allowed Restricted Tiles Toast Location Network R/W ISO store Sockets Most framework APIs Display UI XNA libraries Microphone and Camera Sensors Play audio (may only use background audio APIs)
Background Agents CODE WALK-THROUGH
Background Tips & Lessons Renew often Known issues in beta build SQL CE & memory Debugger (prompts & memory) IsEnabled flag One agent for multiple tasks
A “Mango” to-do app.. Local database + LINQ to SQL Alarms and Reminders Live tiles (secondary tiles) Navigation Background processing FAS, File transfer, Agents
Take on the challenge!! Windows Phone “Mango” Training Kit http://bit.ly/WP7MangoKit Tidy Labs: SQL, Tiles BTS Background Agents Other labs Photo fun SL + XNA Choosers & Launchers Push
Thank You! Q&A jaimer@microsoft.com @jaimerodriguez
© 2008 Microsoft Corporation. All rights reserved © 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.