SlideShare a Scribd company logo
Highlights of What’s
New in Windows
Phone Mango
Glen Gordon
Developer Evangelist, Microsoft
http://glengordon.name
Topics
   Fast Application Switching
   Background Agents
   Live Tiles
   XNA/Silverlight integration




    Windows Phone
Demo

Demo 1:
Fast Application Switching
Application Lifecycle - Dormant App Resume
                                Fast

                                      running
State preserved!
e.IsApplicationInstancePreserved                                  Save State!
== true



                          activated             deactivated




                                      dormant   Phone resources detached
                                                Threads & timers suspended

     Windows Phone
Application Lifecycle - Tombstoned ..
                                Resuming
                                                                     .
Restore state!
e.IsApplicationInstancePreserved
                                             running
== false




                                 activated             deactivated




 Tombstone          Tombstoned               dormant   Phone resources detached
 the oldest                                            Threads & timers suspended
 app
    Windows Phone
Methods & Events




 Windows Phone     6
Finding the Resume type
    private void Application_Activated(object sender, ActivatedEventArgs e)
    {
        if (e.IsApplicationInstancePreserved)
        {
             // Dormant - objects in memory intact
        }
        else
        {
             // Tombstoned - need to reload
        }
    }

   The Activation handler can test a flag to determine the type of resume taking
    place

     Windows Phone
Deactivation Resource Management
                           MediaPlayer.Pause
                           MediaElement.Pause
                       SoundEffectInstance.Pause
                        VibrateController.Stop
                          PhotoCamera.Dispose
                           Save page/global state

                 XNA Audio      Paused
                 Sensors        Notifications suppressed
                 Networking     Cancelled
                 Sockets        Disconnected
                 MediaElement   Disconnected
                 Camera         Disposed

 Windows Phone
Activation Resource Management

                 MediaElement.Source/Position/Play
                 Socket.ConnectAsync
                 new PhotoCamera/VideoCamera

                 Restore app state if tombstoned

                 XNA Audio      Resumed
                 Sensors        Notifications resumed
                 Networking     Completed with Cancellation
                 Sockets        -
                 MediaElement   -
                 Camera         -
 Windows Phone
Isolated Storage vs State Storage
   Isolated storage is so called because the data for an application is isolated from
    all other applications
        It can be used as filestore where an application can store folders and files
        It is slow to access, since it is based on NVRAM technology
        It can also be used to store name/value pairs, e.g. program settings
   State storage is so called because it is used to hold the state of an application
        It can be used to store name/value pairs which are held in memory for
          dormant or tombstoned applications
        It provides very quick access to data

    Windows Phone                                      10
Captain’s Log


Demo
•   With No Storage
•   With Storage
•   Fully Working
Background Tasks
Multitasking Capabilities

   Background Agents
      Periodic
      Resource Intensive
   Background Transfer Service
   Alarms and Reminders
   Background Audio

    Windows Phone                 14
Background Agents
        Agents
             Periodic
             Resource Intensive
        An app may have up to one of each
        Initialized in foreground, run in background
             Persisted across reboots
        User control through Settings
             System maximum of 18 periodic agent
        Agent runs for up to 14 days (can be renewed)


15       Windows Phone
Generic Agent Types
Periodic Agents      Resource Intensive
 Occurrence         Agents
   Every 30 min      Occurrence
 Duration              External power
   ~15 seconds         Non-cell network
 Constraints         Duration
   <= 6 MB Memory      10 minutes
   <=10% CPU         Constraints
                        <= 6 MB Memory
16
Background Agent Functionality
                         Allowed              Restricted
         Tiles
         Toast                       Display UI
         Location                    XNA libraries
         Network                     Microphone and Camera
         R/W ISO store               Sensors
         Sockets                     Play audio
                                       (may only use background audio APIs)
         Most framework APIs


17       Windows Phone
Demo

Demo1: Captain’s Location Log
Debugging a Background Task
    #if DEBUG_AGENT
     ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(60));
    #endif


   It would be annoying if we had to wait 30 minutes to get code in the agent
    running so we could debug it
   When we are debugging we can force service to launch itself
   Such code can be conditionally compiled and removed before the production
    version is built




     Windows Phone                                 19
Debugging the Agent Code
   When you use the Back button or Start on the phone to interrupt an application
    with an active Background Task ,Visual Studio does not stop running
   It remains attached to the application
   You can then put breakpoints into the background task application and debug
    them as you would any other program
   You can single step, view the contents of variables and even change them
    using the Immediate Window
   This is also true if you are working on a device rather than the emulator
   The same techniques work on ResourceIntensiveAgents

    Windows Phone                                    20
Demo

Demo2: Debugging Tasks
File Transfer Tasks
   It is also possible to create a background task to transfer files to and from your
    application’s isolated storage
   The transfers will continue to work even when the application is not running
   An application can monitor the state of the downloads and display their status
   Files can be fetched from HTTP or HTTPs hosts
         At the moment FTP is not supported
   The system maintains a queue of active transfers and services each one in
    turn
   Applications can query the state of active transfers

    Windows Phone                                       22
Background Transfer Policies
   There are a set of policies that control transfer behavior
       Maximum Upload file size: 5Mb
       Maximum Download file size over cellular (mobile phone) data: 20Mb
       Maximum Download file size over WiFi: 100Mb
   These can be modified by setting the value of TransferPreferences on a
    particular transfer




    Windows Phone                                23
Transfer Management
   An application can find out how many file transfers it has active
        It will have to do this when it is restarted, as file transfers will continue even
         when the application is not running
   It can then perform transfer management as required
   There is a good example of transfer list management on MSDN:

                    http://msdn.microsoft.com/en-us/library/hh202953.aspx



    Windows Phone
Demo

Demo3: Picture Fetch
Scheduled Notifications

   Time-based, on-phone notifications
   Supports Alerts & Reminders
   Persist across reboots
   Adheres to user settings
   Consistent with phone UX


    Windows Phone                    26
Alarms vs Reminders?
Alarms                     Reminde
                           rs



 •   Modal                 •   Rich information
 •   Snooze and Dismiss    •   Integrates with other reminders
 •   Sound customization   •   Snooze and Dismiss
 •   No app invocation     •   Launch app
 •   No stacking           •   Follows the phones global settings
27
Creating a Reminder
    using Microsoft.Phone.Scheduler;
    ...
    eggReminder = new Reminder("Egg Timer");

    eggReminder.BeginTime = DateTime.Now + new TimeSpan(0, eggTime, 0);
    eggReminder.Content = "Egg Ready";
    eggReminder.RecurrenceType = RecurrenceInterval.None;
    eggReminder.NavigationUri = new Uri("/EggReadyPage.xaml", UriKind.Relative);

    ScheduledActionService.Add(eggReminder);

   This code creates a reminder and adds it as a scheduled service
   The value eggTime holds the length of the delay
   This code also sets the url of the page in the application
     Windows Phone                                  28
Reminder Housekeeping
    Reminder eggReminder = ScheduledActionService.Find("Egg Timer") as Reminder;

    if ( eggReminder != null )
    {
        ScheduledActionService.Remove("Egg Timer");
    }

   Reminders are identified by name
   This code finds the “Egg Timer” reminder and then removes it from the
    scheduler




     Windows Phone                                    29
Demo

Demo4: Egg Timer
Audio Playback Agents
   It is also possible to create an
    Audio Playback Agent that
    will manage an application
    controlled playlist
   The mechanism is the same
    as for other background
    tasks
   The audio can be streamed
    or held in the application
    isolated storage



    Windows Phone                      31
Background Audio
   Playback
       App provides URL or stream to Zune
       Audio continues to play even if app is closed
       App is notified of file or buffer near completion
   Phone Integration
       Music & Video Hub
       Universal Volume Control (UVC), launch app, controls, contextual info
       Contextual launch – Start menu, UVC, Music & Video Hub
   App Integration
       App can retrieve playback status, progress, & metadata
       Playback notification registration

    Windows Phone                                   32
Demo

Demo 5: Audio
Tiles and
Notifications
Consumer Experience
 Windows phone has the unique
  ability to provide the end user
  glanceable access to the
  information they care most
  about, via Live Tiles
                  +
 Push Notifications offer
  developers a way to send timely
  information to the end user’s
  device even when the
    Windows Phone
Tiles 101
 Shortcuts to apps
 Static or dynamic
 2 sizes: small &
  large
    Large only for 1st

     party apps
 End-user is in
    Windows Phone
Data Driven Template Model

 A fixed set of data properties
 Each property corresponds to a UI
  element
 Each UI element has a fixed position on
  screen
 Not all elements need to be used
    Background Image
     (173 x 173 .png)
                        Title   Count

     Windows Phone
Scenarios/Popular Applications
   Weather Apps            Send to WP7
        Weather Tile            Link Tile
        Warning Toast           Link Toast
   Chess by Post           AlphaJax
        Turn Tile               Turn Tile
        Move Toast              Move Toast
   Beezz                   Seattle Traffic Map
        Unread Tile             Traffic Tile
        Direct Toast



    Windows Phone
Primary and Secondary Tiles
   Application Tile                            Front

     Pinned from App List
     Properties are set initially in the
      Application Manifest                      Bac
                                                k

   Secondary Tile
     New in Windows Phone 7.5!
     Created as a result of user input in an
      application
    Windows Phone
Live Tiles – Local Tile API
   Local tile updates (these are *not* push)
      Full control of all properties when your app
         is in the foreground or background
      Calorie counter, sticky notes
   Multi-Tile!
      Deep-link to specific application sections
      Launch directly to page/experience




    Windows Phone
Live Tiles – Local Tile API
Continued…
   Back of tile updates
      Full control of all properties when your app
       is in the foreground or background
      Content, Title, Background
      Content       Content
      string is                                          Background
      bigger
                              Title   Title



          Flips from front to back at random interval
          Smart logic to make flips asynchronous
    Windows Phone
Demo

Demo 1: Live Tiles – Local Tile API
Tile Schedule
   Periodically updates the tile image without pushing message though
   Updates images only from the web, not from the app local store
   Sets up notification channel and binds it to a tile notification
   Few limitations
      Image size must be less than 80 KB
      Download time must not exceed 60 seconds
      Lowest update time resolution is 60 minutes
      If the schedule for an indefinite or finite number of updates fails
        too many times, OS will cancel it
   Update recurrence can by Onetime, EveryHour, EveryDay,
    EveryWeek or EveryMonth
    Windows Phone
Scheduling Tile Update
public partial class MainPage : PhoneApplicationPage {
    private ShellTileSchedule _mySchedule;
    public MainPage() {
        InitializeComponent();
        ScheduleTile();
    }

     private void ScheduleTile()    {
        _mySchedule = new ShellTileSchedule();
        _mySchedule.Recurrence = UpdateRecurrence.Onetime;
        _mySchedule.StartTime = DateTime.Now;
        _mySchedule.RemoteImageUri = new
                          Uri("http://cdn3.afterdawn.fi/news/small/windows-phone-7-series.png");
        _mySchedule.Start();
    }
}


    Windows Phone
Updating Tiles from a Background
Agent
   In Windows Phone OS 7.0, only way of updating Live Tiles was from a Tile
    Schedule or from Notifications
       Tile Schedule needs to fetch images from
        a web URI
       Notifications require you to implement a
        backend service
   To have control of shell tiles when the app is not running without using Push
    Notifications, a good solution is a Background Agent
          Use the ShellTile API to locate and
           update tiles
    Windows Phone
Demo

Demo 2: Updating Tiles from a Background
Agent
Push Notifications

 Server-initiated communication
 Enable key background scenarios
 Preserve battery life and user
  experience
 Prevent polling for updates

    Windows Phone
Push Notification Data Flow
                                    2                    URI to the service:
                                        "http://notify.live.com/throttledthirdparty/01.00/AAFRQHgiiMWN
                                                                                                                  3rd party
                    Push enabled                                   TYrRDXAHQtz-                                    service
                     applications           AgrNpzcDAwAAAAQOMDAwMDAwMDAwMDAwMDA"
                                                                                                              3
                    Notifications
                      service                                                                            HTTP POST the
                                                                     4                                     message
                                                                                Send PN
                                                                                Message
1      Push endpoint is established. URI is created
                   for the endpoint.
                                                                                                              Microsoft
                                                                                                                hosted
                                                                                                                server




    Windows Phone
Three Kinds of Notifications
   Raw
          Notification message content is application-specific
          Delivered directly to app only if it is running
   Toast
          Specific XML schema
          Content delivered to app if it is running
          If app is not running, system displays Toast popup using notification message content
   Tile
          Specific XML schema
          Never delivered to app
          If user has pinned app tile to Start screen, system updates it using notification message
           content

    Windows Phone
Push Notifications – New Features
   Multi-Tile/Back of Tile Support
      Multiple weather locations, news categories,
       sports team scores, twitter favorites
      Can update all tiles belonging to your application
   No API Change for binding tiles
      BindToShellTile now binds you to all tiles
      Send Tile ID to service and use new attribute to
       direct update
   Three new elements for back of tile properties
    Windows Phone
Toast Notification

 App icon and two text fields
 Time critical and personally relevant
 Users must opt-in via app UI




    Windows Phone
Response Custom Headers
   Response Code: HTTP status code (200 OK)
   Notification Status
          Notification received by the Push Notification Service
          For example: “X-NotificationStatus:Received”
   DeviceConnectionStatus
          The connection status of the device
          //For example: X-DeviceConnectionStatus:Connected
   SubscriptionStatus
          The subscription status
          //For example: X-SubscriptionStatus:Active
   More information
          http://msdn.microsoft.com/en-us/library/ff402545(v=VS.92).aspx

    Windows Phone
XNA and Silverlight
integration
Xna and Silverlight combined

 It is now possible to create an application that
  combines XNA and Silverlight
 The XNA runs within a Silverlight page
 This makes it easy to use XNA to create
  gameplay and Silverlight to build the user
  interface
 Possible to put Silverlight elements onto an XNA
  game screen so the user can interact with both
  elements at the same time
    Windows Phone                                    57
Creating a Combined Project




   This project contains both Silverlight and
    XNA elements
    Windows Phone                                58
A combined solution

 A combined solution contains three
  projects
   The Silverlight project
   An XNA library project
   The content project
 These are created automatically
  by Visual Studio
    Windows Phone                      59
The XNA GamePage
   The XNA gameplay is
    displayed on a specific
    Silverlight page that is
    added to the project when it
    is created
   When this page is
    navigated to the XNA game
    behind it will start running
   However, the Silverlight
    system is still active around
    Windows Phone                   60
Starting a Combined Application
 When the combined
  application starts the
  MainPage is displayed
 It contains a button that can
  be used to navigate to the
  game page
 You can build your own
    Windows Phone                 61
Navigating to the game page
private void Button_Click(object sender,
                           RoutedEventArgs e)
{
    NavigationService.Navigate(new Uri("/GamePage.xaml",
                                UriKind.Relative));
}


   This is the button event hander in
    MainPage.xaml.cs
   Navigating to the page will trigger the XNA
    gameplay to start
    Windows Phone
The game page
protected override void OnNavigatedTo(NavigationEventArgs e)
protected override void OnNavigatedFrom(NavigationEventArgs e)
private void OnUpdate(object sender, GameTimerEventArgs e)
private void OnDraw(object sender, GameTimerEventArgs e)

     These are the methods on the game page that contorl
      gameplay
        OnNavigatedTo will do the job of the Initialize and
         LoadContent methods
        OnNavigatedFrom is used to suspend the game
        OnUpdate is the Update method
        OnDraw is the Draw method
      Windows Phone
Combining XNA and Silverlight
    <!--No XAML content is required as the page is rendered
    entirely with the XNA Framework-->


 The default combined project does not contain
  any XAML content for the XNA page
 If XAML elements are added to this page they will
  not be displayed without some extra code
    The Silverlight page is rendered to a texture
      which is drawn in the XNA game
 We have to add the code to do this
     Windows Phone
Demo
6: Silverlight and XNA
Summary

 Get the new tools at
  http://create.msdn.com
 Windows Phone Mango Jumpstart




    Windows Phone                 66

More Related Content

PDF
follow-app BOOTCAMP 2: Windows phone fast application switching
QIRIS
 
PPTX
Cool Stuff Your App Can Do
Ed Donahue
 
PDF
TOMOYO Linux on Android (Taipei, 2009)
Toshiharu Harada, Ph.D
 
PPTX
Video Surveillance System
Ali Mattash
 
PPTX
Indian nuclear power programme
NIT Puducherry
 
PDF
Fundamentals Of Rockets & Missiles
Jim Jenkins
 
PPTX
Future of the Internet
Yogi Schulz
 
PPTX
Guided missiles
Avinash Kharche
 
follow-app BOOTCAMP 2: Windows phone fast application switching
QIRIS
 
Cool Stuff Your App Can Do
Ed Donahue
 
TOMOYO Linux on Android (Taipei, 2009)
Toshiharu Harada, Ph.D
 
Video Surveillance System
Ali Mattash
 
Indian nuclear power programme
NIT Puducherry
 
Fundamentals Of Rockets & Missiles
Jim Jenkins
 
Future of the Internet
Yogi Schulz
 
Guided missiles
Avinash Kharche
 

Viewers also liked (8)

PPTX
Missile guidance
Pankaj Kumar
 
PPTX
Internet 2020: The Future Connection
Christine Nolan
 
PPTX
PPT ON GUIDED MISSILES
Sneha Jha
 
PPTX
Green computing ppt
neenasahni
 
PPT
India Nuclear Weapon Programs Ppt
guest99f39df
 
PPT
Missile Technology
Ashwin Baindur
 
PPTX
Robotics project ppt
Vundavalli Shreya
 
PDF
[Infographic] How will Internet of Things (IoT) change the world as we know it?
InterQuest Group
 
Missile guidance
Pankaj Kumar
 
Internet 2020: The Future Connection
Christine Nolan
 
PPT ON GUIDED MISSILES
Sneha Jha
 
Green computing ppt
neenasahni
 
India Nuclear Weapon Programs Ppt
guest99f39df
 
Missile Technology
Ashwin Baindur
 
Robotics project ppt
Vundavalli Shreya
 
[Infographic] How will Internet of Things (IoT) change the world as we know it?
InterQuest Group
 
Ad

Similar to What's new in Windows Phone Mango for Developers (20)

PPTX
Windows Phone Fast App Switching, Tombstoning and Multitasking
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PPTX
Windows Phone Application Platform
Dave Bost
 
PDF
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?
soft-shake.ch
 
PDF
Windows Phone 8 Fundamental
Nguyên Phạm
 
PDF
Windows phone 7 series
openbala
 
PPTX
Windows Phone 8 - 6 Background Agents
Oliver Scheer
 
PPTX
Windows 8 BootCamp
Einar Ingebrigtsen
 
PPTX
An end-to-end experience of Windows Phone 7 development (Part 1)
rudigrobler
 
PPTX
Windows Phone 7.5 Mango - What's New
Sascha Corti
 
PPTX
Windows Phone: multitasking and local database
Radu Vunvulea
 
PPTX
Windows Phone 8 - 5 Application Lifecycle
Oliver Scheer
 
PPTX
Session 1
Anwar Yahyawi
 
PDF
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
QIRIS
 
PPTX
09 wp7 multitasking
Tao Wang
 
PPTX
11 background tasks and multitasking
WindowsPhoneRocks
 
PPTX
Windows Phone Launchers and Choosers
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PDF
Windows phone 8 session 2
hitesh chothani
 
PPTX
Zadar Developers Hub - Windows Phone Development
Niko Vrdoljak
 
PPTX
WP7 HUB_Creando aplicaciones de Windows Phone
MICTT Palma
 
PDF
Windows phone 8 session 9
hitesh chothani
 
Windows Phone Fast App Switching, Tombstoning and Multitasking
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
Windows Phone Application Platform
Dave Bost
 
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?
soft-shake.ch
 
Windows Phone 8 Fundamental
Nguyên Phạm
 
Windows phone 7 series
openbala
 
Windows Phone 8 - 6 Background Agents
Oliver Scheer
 
Windows 8 BootCamp
Einar Ingebrigtsen
 
An end-to-end experience of Windows Phone 7 development (Part 1)
rudigrobler
 
Windows Phone 7.5 Mango - What's New
Sascha Corti
 
Windows Phone: multitasking and local database
Radu Vunvulea
 
Windows Phone 8 - 5 Application Lifecycle
Oliver Scheer
 
Session 1
Anwar Yahyawi
 
follow-app BOOTCAMP 2: Building windows phone applications with visual studio...
QIRIS
 
09 wp7 multitasking
Tao Wang
 
11 background tasks and multitasking
WindowsPhoneRocks
 
Windows phone 8 session 2
hitesh chothani
 
Zadar Developers Hub - Windows Phone Development
Niko Vrdoljak
 
WP7 HUB_Creando aplicaciones de Windows Phone
MICTT Palma
 
Windows phone 8 session 9
hitesh chothani
 
Ad

More from Glen Gordon (8)

PPTX
Windows Phone Garage - Application Jumpstart
Glen Gordon
 
PPTX
OData for iOS developers
Glen Gordon
 
PPTX
Windows Phone 7 Services
Glen Gordon
 
PPTX
Windows Phone 7 and Silverlight
Glen Gordon
 
PPTX
Windows phone 7 xna
Glen Gordon
 
PPTX
XNA and Windows Phone
Glen Gordon
 
PPTX
Introduction to Microsoft Silverlight
Glen Gordon
 
PPTX
Microsoft Web Platform and Internet Explorer 8 for PHP developers
Glen Gordon
 
Windows Phone Garage - Application Jumpstart
Glen Gordon
 
OData for iOS developers
Glen Gordon
 
Windows Phone 7 Services
Glen Gordon
 
Windows Phone 7 and Silverlight
Glen Gordon
 
Windows phone 7 xna
Glen Gordon
 
XNA and Windows Phone
Glen Gordon
 
Introduction to Microsoft Silverlight
Glen Gordon
 
Microsoft Web Platform and Internet Explorer 8 for PHP developers
Glen Gordon
 

Recently uploaded (20)

PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
The Future of Artificial Intelligence (AI)
Mukul
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 

What's new in Windows Phone Mango for Developers

  • 1. Highlights of What’s New in Windows Phone Mango Glen Gordon Developer Evangelist, Microsoft http://glengordon.name
  • 2. Topics  Fast Application Switching  Background Agents  Live Tiles  XNA/Silverlight integration Windows Phone
  • 4. Application Lifecycle - Dormant App Resume Fast running State preserved! e.IsApplicationInstancePreserved Save State! == true activated deactivated dormant Phone resources detached Threads & timers suspended Windows Phone
  • 5. Application Lifecycle - Tombstoned .. Resuming . Restore state! e.IsApplicationInstancePreserved running == false activated deactivated Tombstone Tombstoned dormant Phone resources detached the oldest Threads & timers suspended app Windows Phone
  • 6. Methods & Events Windows Phone 6
  • 7. Finding the Resume type private void Application_Activated(object sender, ActivatedEventArgs e) { if (e.IsApplicationInstancePreserved) { // Dormant - objects in memory intact } else { // Tombstoned - need to reload } }  The Activation handler can test a flag to determine the type of resume taking place Windows Phone
  • 8. Deactivation Resource Management MediaPlayer.Pause MediaElement.Pause SoundEffectInstance.Pause VibrateController.Stop PhotoCamera.Dispose Save page/global state XNA Audio Paused Sensors Notifications suppressed Networking Cancelled Sockets Disconnected MediaElement Disconnected Camera Disposed Windows Phone
  • 9. Activation Resource Management MediaElement.Source/Position/Play Socket.ConnectAsync new PhotoCamera/VideoCamera Restore app state if tombstoned XNA Audio Resumed Sensors Notifications resumed Networking Completed with Cancellation Sockets - MediaElement - Camera - Windows Phone
  • 10. Isolated Storage vs State Storage  Isolated storage is so called because the data for an application is isolated from all other applications  It can be used as filestore where an application can store folders and files  It is slow to access, since it is based on NVRAM technology  It can also be used to store name/value pairs, e.g. program settings  State storage is so called because it is used to hold the state of an application  It can be used to store name/value pairs which are held in memory for dormant or tombstoned applications  It provides very quick access to data Windows Phone 10
  • 11. Captain’s Log Demo • With No Storage • With Storage • Fully Working
  • 13. Multitasking Capabilities  Background Agents  Periodic  Resource Intensive  Background Transfer Service  Alarms and Reminders  Background Audio Windows Phone 14
  • 14. Background Agents  Agents  Periodic  Resource Intensive  An app may have up to one of each  Initialized in foreground, run in background  Persisted across reboots  User control through Settings  System maximum of 18 periodic agent  Agent runs for up to 14 days (can be renewed) 15 Windows Phone
  • 15. Generic Agent Types Periodic Agents Resource Intensive  Occurrence Agents  Every 30 min  Occurrence  Duration  External power  ~15 seconds  Non-cell network  Constraints  Duration  <= 6 MB Memory  10 minutes  <=10% CPU  Constraints  <= 6 MB Memory 16
  • 16. Background Agent Functionality Allowed Restricted  Tiles  Toast  Display UI  Location  XNA libraries  Network  Microphone and Camera  R/W ISO store  Sensors  Sockets  Play audio (may only use background audio APIs)  Most framework APIs 17 Windows Phone
  • 18. Debugging a Background Task #if DEBUG_AGENT ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(60)); #endif  It would be annoying if we had to wait 30 minutes to get code in the agent running so we could debug it  When we are debugging we can force service to launch itself  Such code can be conditionally compiled and removed before the production version is built Windows Phone 19
  • 19. Debugging the Agent Code  When you use the Back button or Start on the phone to interrupt an application with an active Background Task ,Visual Studio does not stop running  It remains attached to the application  You can then put breakpoints into the background task application and debug them as you would any other program  You can single step, view the contents of variables and even change them using the Immediate Window  This is also true if you are working on a device rather than the emulator  The same techniques work on ResourceIntensiveAgents Windows Phone 20
  • 21. File Transfer Tasks  It is also possible to create a background task to transfer files to and from your application’s isolated storage  The transfers will continue to work even when the application is not running  An application can monitor the state of the downloads and display their status  Files can be fetched from HTTP or HTTPs hosts  At the moment FTP is not supported  The system maintains a queue of active transfers and services each one in turn  Applications can query the state of active transfers Windows Phone 22
  • 22. Background Transfer Policies  There are a set of policies that control transfer behavior  Maximum Upload file size: 5Mb  Maximum Download file size over cellular (mobile phone) data: 20Mb  Maximum Download file size over WiFi: 100Mb  These can be modified by setting the value of TransferPreferences on a particular transfer Windows Phone 23
  • 23. Transfer Management  An application can find out how many file transfers it has active  It will have to do this when it is restarted, as file transfers will continue even when the application is not running  It can then perform transfer management as required  There is a good example of transfer list management on MSDN: http://msdn.microsoft.com/en-us/library/hh202953.aspx Windows Phone
  • 25. Scheduled Notifications  Time-based, on-phone notifications  Supports Alerts & Reminders  Persist across reboots  Adheres to user settings  Consistent with phone UX Windows Phone 26
  • 26. Alarms vs Reminders? Alarms Reminde rs • Modal • Rich information • Snooze and Dismiss • Integrates with other reminders • Sound customization • Snooze and Dismiss • No app invocation • Launch app • No stacking • Follows the phones global settings 27
  • 27. Creating a Reminder using Microsoft.Phone.Scheduler; ... eggReminder = new Reminder("Egg Timer"); eggReminder.BeginTime = DateTime.Now + new TimeSpan(0, eggTime, 0); eggReminder.Content = "Egg Ready"; eggReminder.RecurrenceType = RecurrenceInterval.None; eggReminder.NavigationUri = new Uri("/EggReadyPage.xaml", UriKind.Relative); ScheduledActionService.Add(eggReminder);  This code creates a reminder and adds it as a scheduled service  The value eggTime holds the length of the delay  This code also sets the url of the page in the application Windows Phone 28
  • 28. Reminder Housekeeping Reminder eggReminder = ScheduledActionService.Find("Egg Timer") as Reminder; if ( eggReminder != null ) { ScheduledActionService.Remove("Egg Timer"); }  Reminders are identified by name  This code finds the “Egg Timer” reminder and then removes it from the scheduler Windows Phone 29
  • 30. Audio Playback Agents  It is also possible to create an Audio Playback Agent that will manage an application controlled playlist  The mechanism is the same as for other background tasks  The audio can be streamed or held in the application isolated storage Windows Phone 31
  • 31. Background Audio  Playback  App provides URL or stream to Zune  Audio continues to play even if app is closed  App is notified of file or buffer near completion  Phone Integration  Music & Video Hub  Universal Volume Control (UVC), launch app, controls, contextual info  Contextual launch – Start menu, UVC, Music & Video Hub  App Integration  App can retrieve playback status, progress, & metadata  Playback notification registration Windows Phone 32
  • 34. Consumer Experience  Windows phone has the unique ability to provide the end user glanceable access to the information they care most about, via Live Tiles +  Push Notifications offer developers a way to send timely information to the end user’s device even when the Windows Phone
  • 35. Tiles 101  Shortcuts to apps  Static or dynamic  2 sizes: small & large  Large only for 1st party apps  End-user is in Windows Phone
  • 36. Data Driven Template Model  A fixed set of data properties  Each property corresponds to a UI element  Each UI element has a fixed position on screen  Not all elements need to be used Background Image (173 x 173 .png) Title Count Windows Phone
  • 37. Scenarios/Popular Applications  Weather Apps  Send to WP7  Weather Tile  Link Tile  Warning Toast  Link Toast  Chess by Post  AlphaJax  Turn Tile  Turn Tile  Move Toast  Move Toast  Beezz  Seattle Traffic Map  Unread Tile  Traffic Tile  Direct Toast Windows Phone
  • 38. Primary and Secondary Tiles  Application Tile Front  Pinned from App List  Properties are set initially in the Application Manifest Bac k  Secondary Tile  New in Windows Phone 7.5!  Created as a result of user input in an application Windows Phone
  • 39. Live Tiles – Local Tile API  Local tile updates (these are *not* push)  Full control of all properties when your app is in the foreground or background  Calorie counter, sticky notes  Multi-Tile!  Deep-link to specific application sections  Launch directly to page/experience Windows Phone
  • 40. Live Tiles – Local Tile API Continued…  Back of tile updates  Full control of all properties when your app is in the foreground or background  Content, Title, Background Content Content string is Background bigger Title Title  Flips from front to back at random interval  Smart logic to make flips asynchronous Windows Phone
  • 41. Demo Demo 1: Live Tiles – Local Tile API
  • 42. Tile Schedule  Periodically updates the tile image without pushing message though  Updates images only from the web, not from the app local store  Sets up notification channel and binds it to a tile notification  Few limitations  Image size must be less than 80 KB  Download time must not exceed 60 seconds  Lowest update time resolution is 60 minutes  If the schedule for an indefinite or finite number of updates fails too many times, OS will cancel it  Update recurrence can by Onetime, EveryHour, EveryDay, EveryWeek or EveryMonth Windows Phone
  • 43. Scheduling Tile Update public partial class MainPage : PhoneApplicationPage { private ShellTileSchedule _mySchedule; public MainPage() { InitializeComponent(); ScheduleTile(); } private void ScheduleTile() { _mySchedule = new ShellTileSchedule(); _mySchedule.Recurrence = UpdateRecurrence.Onetime; _mySchedule.StartTime = DateTime.Now; _mySchedule.RemoteImageUri = new Uri("http://cdn3.afterdawn.fi/news/small/windows-phone-7-series.png"); _mySchedule.Start(); } } Windows Phone
  • 44. Updating Tiles from a Background Agent  In Windows Phone OS 7.0, only way of updating Live Tiles was from a Tile Schedule or from Notifications  Tile Schedule needs to fetch images from a web URI  Notifications require you to implement a backend service  To have control of shell tiles when the app is not running without using Push Notifications, a good solution is a Background Agent  Use the ShellTile API to locate and update tiles Windows Phone
  • 45. Demo Demo 2: Updating Tiles from a Background Agent
  • 46. Push Notifications  Server-initiated communication  Enable key background scenarios  Preserve battery life and user experience  Prevent polling for updates Windows Phone
  • 47. Push Notification Data Flow 2 URI to the service: "http://notify.live.com/throttledthirdparty/01.00/AAFRQHgiiMWN 3rd party Push enabled TYrRDXAHQtz- service applications AgrNpzcDAwAAAAQOMDAwMDAwMDAwMDAwMDA" 3 Notifications service HTTP POST the 4 message Send PN Message 1 Push endpoint is established. URI is created for the endpoint. Microsoft hosted server Windows Phone
  • 48. Three Kinds of Notifications  Raw  Notification message content is application-specific  Delivered directly to app only if it is running  Toast  Specific XML schema  Content delivered to app if it is running  If app is not running, system displays Toast popup using notification message content  Tile  Specific XML schema  Never delivered to app  If user has pinned app tile to Start screen, system updates it using notification message content Windows Phone
  • 49. Push Notifications – New Features  Multi-Tile/Back of Tile Support  Multiple weather locations, news categories, sports team scores, twitter favorites  Can update all tiles belonging to your application  No API Change for binding tiles  BindToShellTile now binds you to all tiles  Send Tile ID to service and use new attribute to direct update  Three new elements for back of tile properties Windows Phone
  • 50. Toast Notification  App icon and two text fields  Time critical and personally relevant  Users must opt-in via app UI Windows Phone
  • 51. Response Custom Headers  Response Code: HTTP status code (200 OK)  Notification Status  Notification received by the Push Notification Service  For example: “X-NotificationStatus:Received”  DeviceConnectionStatus  The connection status of the device  //For example: X-DeviceConnectionStatus:Connected  SubscriptionStatus  The subscription status  //For example: X-SubscriptionStatus:Active  More information  http://msdn.microsoft.com/en-us/library/ff402545(v=VS.92).aspx Windows Phone
  • 53. Xna and Silverlight combined  It is now possible to create an application that combines XNA and Silverlight  The XNA runs within a Silverlight page  This makes it easy to use XNA to create gameplay and Silverlight to build the user interface  Possible to put Silverlight elements onto an XNA game screen so the user can interact with both elements at the same time Windows Phone 57
  • 54. Creating a Combined Project  This project contains both Silverlight and XNA elements Windows Phone 58
  • 55. A combined solution  A combined solution contains three projects  The Silverlight project  An XNA library project  The content project  These are created automatically by Visual Studio Windows Phone 59
  • 56. The XNA GamePage  The XNA gameplay is displayed on a specific Silverlight page that is added to the project when it is created  When this page is navigated to the XNA game behind it will start running  However, the Silverlight system is still active around Windows Phone 60
  • 57. Starting a Combined Application  When the combined application starts the MainPage is displayed  It contains a button that can be used to navigate to the game page  You can build your own Windows Phone 61
  • 58. Navigating to the game page private void Button_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative)); }  This is the button event hander in MainPage.xaml.cs  Navigating to the page will trigger the XNA gameplay to start Windows Phone
  • 59. The game page protected override void OnNavigatedTo(NavigationEventArgs e) protected override void OnNavigatedFrom(NavigationEventArgs e) private void OnUpdate(object sender, GameTimerEventArgs e) private void OnDraw(object sender, GameTimerEventArgs e)  These are the methods on the game page that contorl gameplay  OnNavigatedTo will do the job of the Initialize and LoadContent methods  OnNavigatedFrom is used to suspend the game  OnUpdate is the Update method  OnDraw is the Draw method Windows Phone
  • 60. Combining XNA and Silverlight <!--No XAML content is required as the page is rendered entirely with the XNA Framework-->  The default combined project does not contain any XAML content for the XNA page  If XAML elements are added to this page they will not be displayed without some extra code  The Silverlight page is rendered to a texture which is drawn in the XNA game  We have to add the code to do this Windows Phone
  • 62. Summary  Get the new tools at http://create.msdn.com  Windows Phone Mango Jumpstart Windows Phone 66