WP7 Tpa 10 Reminders Agents

Embed Size (px)

Citation preview

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    1/25

    TPA - Windows Phone

    Alarms & remainders, Live tiles

    Background agents

    Prepared by: Kamil Kowalski

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    2/25

    Agenda

    Reminders

    Alarms

    Live Tiles

    Application tile

    Secondary tiles

    Tiles properties

    Background agents Constraints

    Q & A

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    3/25

    Reminders

    Reminders on Windows Phone are a way to alert user thatsomething needs to be done.

    The obvious applications of a reminder are an alarm clock, a calendar,

    or a to-do list.

    Each Reminder must have a name and this name will be used

    during management of events in the future.

    Each Reminder should have a unique name for management

    purpose.

    If the name doesnt matter to you, or you dont plan on managing

    remainders, you can use a simple timestamp as name, which should

    guarantee a unique name each time.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    4/25

    Reminders

    How to use it Main elements:

    Name unique Name for the Reminder.

    Title visible title.

    Contentcontent for the reminder.

    Begin Time start time of the Reminder.

    Expiration Time expiration time of the Reminder (not required).

    Recurrence Type recurrence type of the Reminder.

    Navigation URI on clicking of the application will navigate the user to thenew page (relative path).

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    5/25

    Alarms

    Alarms on Windows Phone are other way to alert user thatsomething needs to be done.

    Alarms are nearly identical to Reminders, with a couple of

    exceptions:

    Alarms cant specify a Title property, and they also cant use theNavigationUri property.

    They can play a custom sound.

    Reminders and Alarms can be managed by

    ScheduledActionServiceclass, which allows to: add, edit,

    search, delete reminders & alarms as needed.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    6/25

    Alarms

    How to use it Main elements:

    Nameunique name for the Alarm

    Title visible title

    Content content for the alarm

    Begin Time start time of the alarm

    Expiration Time expiration time of the alarm

    Recurrence Type recurrence type of the alarm

    Soundsound file to play for the alarm

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    7/25

    Live Tiles

    Tile is a link to an application displayed in Start. There aretwo types of Tiles Application Tiles and secondary Tiles.

    TheApplication Tile is created when a user pins anapplication to Start by pressing and holding the application'sicon in the Applications List.

    Tapping a pinned Application Tile navigates the user to theapplications opening page.

    A secondary Tile is created programmatically by anapplication based on interaction from the user.

    The application's code provides the Tile with launch parameters to

    customize the navigation destination of the Tile.

    Application can have secondary tiles for an application on Startwithout having an Application Tile.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    8/25

    Live TilesApplication tile

    Application tile can be created by the user only. When the user taps and holds the application name in the Application

    List and then selects pin to start.

    Properties are initially set in the Application Manifest.

    Application tile cannot be deleted.

    The Application Tile may or may not be pinned to Start.

    Even if the user has not pinned the Application Tile to Start, it can be

    updated programmatically such that its property data will be fresh

    should the user decide to pin it.

    Application tile can be updated by: ShellTileSchedule APIs

    ShellTile APIs - it is always the first item in the ActiveTiles collection,

    even if the Tile is not pinned to Start.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    9/25

    Live TilesSecondary tiles

    Secondary Tiles can be created only as the result of userinput in an application.

    Secondary Tile can be deleted by:

    The user unpinning the Tile from Start.

    Calling delete method. Secondary Tile can be updated by:

    ShellTile APIs

    ShellTileSchedule APIs

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    10/25

    Application TilesTile properties

    Starting in Windows Phone OS 7.1, Tiles are two sided. Tilesdisplay information by flipping between the front and

    back sides of the Tile.

    If none of the properties on the back side of the Tile are set, the Tile

    will not flip over and only the front side of the Tile will be displayed.

    Front of a Tile:

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    11/25

    Application TilesTile properties

    The properties of the front of a Tile are: Title - indicates the title of the application.

    The Title must fit on a single line of text and should not be wider thanthe actual Tile. Approximately 15 characters will fit in the title beforebeing truncated.

    BackgroundImage - image displayed on the front of the Tile. Count (also known as Badge) - integer value from 1 to 99.

    If the value of Count is not set or it is set to 0, the circle image and valuewill not display in the Tile.

    The properties of the back of a Tile are:

    BackTitle - string displayed at the bottom of the back of a Tile.

    The BackTitle must fit on a single line of text and should not be widerthan the actual Tile. Approximately 15 characters will fit in the titlebefore being truncated.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    12/25

    Application TilesTile properties

    BackBackgroundImage - displayed on the back of the Tile. BackContent - string displayed in the body of the back of a Tile.

    Approximately 40 characters will fit in the Tile before being truncated.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    13/25

    Application TilesImages for tiles

    Notes on the images used for the BackgroundImage and theBackBackgroundImage properties: Tile images can be either a .jpg or .png file, but you should use .jpg for

    performance reasons.

    You should use local images for tiles (because of network variability andperformance reasons).

    Using a .png with transparent portions to the image will allow the userstheme color to show through.

    Tiles are 173 x 173 pixels. If the image you provide has differentdimensions, it will be stretched to fit 173 x 173.

    https is not supported for remote images.

    Remote images are limited to 80 KB or less or they will not bedownloaded.

    Remote images must download in 30 seconds or less or they will not bedownloaded.

    If the BackGround or BackBackGround images fail to load for any reason,none of the other properties set in the update will be changed either.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    14/25

    Application TilesWorking With Tiles

    The the following approches/SDK elements can be used towork with Tiles:

    ShellTile APIs Secondary Tiles can be created and deleted with

    these APIs. The Application Tile and secondary Tiles can be updated

    by using these APIs.

    ShellTileSchedule APIs The background images on the front of a Tilecan be updated on a recurring schedule, even if your application is

    not running.

    Application Manifest File for Windows Phone The initial properties

    for an Application Tile can be set in the application manifest file.

    Tile Notifications Tile properties can be updated by using the

    Microsoft Push Notification Service. (check next lecture for details

    concerning Push Notification)

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    15/25

    Application TilesWorking With Tiles

    Things to remember: Each time that you create a secondary tile, the user will be taken to

    their home screen to view it.

    You cant create more than one secondary tile at a time.

    Cluttering up your users home screen is not always a good idea.

    Dont give them a secondary tile unless theres really a reason for

    one. It will get annoying.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    16/25

    Background Agents

    Multitasking capabilities in Windows Phone 7.5 (Mango) arecomprised of several features:

    Fast Application Switching

    Background Agents

    Background File Transfer for detail check here

    Background Audio Playback for detail check here

    Scheduled Notifications (check next lecture for details)

    Background agents allow an application to execute code in

    the background, even when the application is not running in

    the foreground.

    IMPORTANT NOTE: Background agents are not supported on

    256-MB (Tango) devices.

    http://msdn.microsoft.com/en-us/library/hh202953(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh394039(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh394039(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202953(v=vs.92).aspx
  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    17/25

    Background Agents

    There are two types of Background Agents: Periodicand ResourceIntensive. Periodic agents run for a small amount of time on a regular recurring

    interval.

    Typical scenarios for this type of task include uploading the devices locationand performing small amounts of data synchronization.

    Resource-intensive agents run for a relatively long period of time whenthe phone meets a set of requirements relating to processor activity,power source, and network connection.

    A typical scenario for this type of task is synchronizing large amounts of datato the phone while it is not being actively used by the user.

    An application may have only one background agent. This agentcan be registered as a PeriodicTask, a ResourceIntensiveTask, orboth. The schedule on which the agent runs depends on which type of task it is

    registered as.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    18/25

    Background AgentsConstraints

    There is a set of APIs that cannot be used by any BackgroundAgents. Using these APIs either will cause an exception to be thrown at run time

    or will cause the application to fail certification during submission toWindows Phone Marketplace.

    For the list of restricted APIs, see Unsupported APIs for BackgroundAgents for Windows Phone.

    Periodic agents and resource-intensive agents can use no morethan 6 MB of memory at any time. Audio agents are restricted to15 MB. If a Scheduled Task (one of agents) exceeds this memory cap, it is

    terminated immediately.

    When running under the debugger, memory and timeout restrictions aresuspended.

    You can use the ApplicationMemoryUsageLimit API to query the memorylimit for both foreground applications and background agents.

    http://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspx
  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    19/25

    Background AgentsConstraints

    Background Agent requires reschedule every two weeks. When the application associated with the task is run in the

    foreground, it may reschedule the task and reset the expiration time

    to up two weeks from the current time.

    Both periodic and resource-intensive agents are unscheduled

    if they exit two consecutive times due to exceeding the

    memory quota or any other unhandled exception.

    Then agents must be rescheduled by the foreground application.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    20/25

    Background AgentsConstraints for Periodic Agents

    Periodic agents typically run every 30 minutes. To optimize battery life, periodic agents may be run in alignment with

    other background processes and therefore the execution time may

    drift by up to 10 minutes.

    Periodic agents typically run for 25 seconds.

    However there are other constraints that may cause an agent to be

    terminated early.

    Battery Saver mode can prevent execution

    Battery Saver mode is an option that the user can enable on the

    device to indicate that battery life should be prioritized. If this mode is enabled, periodic agents may not run, even if the

    interval has elapsed.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    21/25

    Background AgentsConstraints for Periodic Agents

    To help maximize the battery life of the device, there is a hardlimit on the number of periodic agents that can be scheduled

    on the phone.

    It varies per device configuration and can be as low as 6.

    There is another limit, which is lower than the hard limit, after which

    the user is warned that they have multiple background agents

    running and may, therefore, experience faster battery consumption.

    If you attempt to add a periodic background agent when the devices

    limit has been exceeded, the add operation will throw an

    InvalidOperationException.

    Because the per-device limit on periodic agents is low, it is likely that

    your application will encounter this exception.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    22/25

    Background AgentsConstraints for Resource-intensive Agents

    Resource-intensive agents typically run for 10 minutes. Thereare other constraints that may cause an agent to beterminated early.

    Resource-intensive agents do not run unless the device isconnected to an external power source.

    Resource-intensive agents do not run unless the device has anetwork connection over Wi-Fi or through a connection to aPC.

    Resource-intensive agents do not run unless the devices

    battery power is greater than 90%. Resource-intensive agents do not run unless the device

    screen is locked.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    23/25

    Background AgentsConstraints for Resource-intensive Agents

    Resource-intensive agents cannot change network to cellular. If a device reaches a state where all of the required

    conditions are met and a resource-intensive agent is

    launched, and then the device state changes so that any of

    the conditions are not met, the resource-intensive agent isterminated immediately.

    Due to the constraints on the device that must be met for

    resource-intensive agents to run, it is possible that the agent

    will never be run on a particular device.

  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    24/25

    Background Agents

    How to create background agent: Background Agents have their own project in VS, which should be

    added as a project reference to the application that will start the

    agent.

    Adding this project as the reference will automatically updates

    WMAppManifest.xml file with special entry. In your agent class you need to override OnInvoke() method.

    When your task is completed you need to call NotifyComplete() or

    Abort() method.

    Background Agent Best Practices for Windows Phone.

    http://msdn.microsoft.com/en-us/library/hh202944(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202944(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202944(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202944(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/hh202944(v=vs.92).aspx
  • 8/2/2019 WP7 Tpa 10 Reminders Agents

    25/25

    Q & A

    ??