WP7 Tpa 7 Choosers Launchers

Embed Size (px)

Citation preview

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    1/20

    TPA - Windows Phone

    Tasks, APIs,

    Device Information

    Prepared by: Kamil Kowalski

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    2/20

    Agenda

    Tasks

    Launchers

    Choosers

    APIs Contacts

    Calendar

    Device Information Q & A

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    3/20

    Tasks

    Since Windows Phone platform does not allow multitaskingwe can only have a single application running.

    In addition each application has its own private storage locationwhich other applications can not access.

    Task in WP7 API is used to launch some of the built in

    application, which offers snippet of functionality to performsome manipulations on the external resorces, built inapplications.

    For Tasks we need a reference to Microsoft.Phone.Tasksnamespace.

    NOTICE: some of them just plain dont work in WP emulator.

    For example, the EmailComposeTask assumes you have an emailaccount set up on the device. Because the emulator prevents youfrom creating email accounts, you wont be able to test this.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    4/20

    Launchers

    Launcher task can be described as fire-and-forgetmechanism.

    There is no data or result returned by launcher.

    We cannot say how the launcher task was finished by user!

    Launchers have some general steps to launch the particularfunctionality and steps are as follows:

    Creating an instance of the task

    Setting the parameters to organize the task

    Calling the show method to invoke the task

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    5/20

    Launchers

    SMSComposeTask launches the Messaging application, and presents the userwith the ability to send a text message. You can specify recipients and message

    body, but the user has to send it.

    EmailComposeTask this task is used to send Email message, by Email

    Composing screen with the options to load the data which we can be specified as

    static or dynamic from code. The Email will not be sent unless and until the user

    presses the Send button. PhoneCallTask launches the Phone application and displays the provided phone

    number and name. The phone call isnt dialed until the user presses Call.

    WebBrowserTask launches the Web Browser, and navigates to the specified

    URL.

    MediaPlayerLauncher launches the internal Media Player application, and playsthe media files of our choice or by playing them randomly. Also we have options

    to make use of some of the properties like rewind, pause, forward etc to make it

    much easier to perform.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.smscomposetask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.emailcomposetask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.phonecalltask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.webbrowsertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.mediaplayerlauncher_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.mediaplayerlauncher_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.webbrowsertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.phonecalltask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.emailcomposetask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.smscomposetask_members(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    6/20

    Launchers

    ConnectionSettingsTask

    a task that allows you to direct your users to their wi-fi,bluetooth, and other settings of their device.

    BingMapsTask you can use this task to launch a map with a specific point

    labeled.

    BingMapsDirectionsTaskallows you to provide turn by turn directions from

    either a start AND end point, or from the users current location to an end point .

    NOTICE: encoding for names of start and the end points may not work correctly.

    SearchTask think of this as a way to provide a Bing search from your application.

    ShareLinkTask This task is used to share some links to the social networking

    sites, we can use this task to launch from our application and share some links to

    the network.

    MarketplaceDetailTask launches the Windows Phone Marketplace, and takesthe user to a specific product offering.

    MarketplaceHubTask launched the Windows Phone Marketplace, and allows

    you to specify a category of applications to show by default.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.connectionsettingstask(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.bingmapstask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.bingmapsdirectionstask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.searchtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.sharelinktask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacedetailtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacehubtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacehubtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacedetailtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.sharelinktask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.searchtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.bingmapsdirectionstask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.bingmapstask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.connectionsettingstask(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    7/20

    Launchers

    MarketplaceReviewTask takes the user to the Windows Phone Marketplace toreview the current application.

    MarketplaceSearchTask launches search results for the Windows Phone

    Marketplace, based on a search term your user enters (or that you specify.)

    http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacereviewtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacesearchtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacesearchtask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.marketplacereviewtask_members(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    8/20

    Choosers

    Choosers are a little more complicated (than Launchers),because they return data to your application (where a

    Launcher just gives the user a new task to accomplish).

    Choosers have some general steps to launch a particular

    application and steps are as follows: Creating an instance of the task

    Identifying the callback method to run after the task completes

    Setting the parameters to organize the task

    Calling the show method to invoke the task

    Implementing the completed event handler to get the data and

    status.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    9/20

    Choosers

    EmailAddressChooserTask allows your user to select an email address fromtheir contacts to use in your application.

    SaveContactTaskis used to launch the contact application in order to save the

    contact details of a contact to the contact details section.

    SaveEmailAddressTask is used to launch the contact application in order to save

    an email address of a contact to the contact details section.

    SavePhoneNumberTask This task is used to launch the contact application in

    order to save a phone number to the contact details from the application which

    triggered this task.

    CameraCaptureTask gives your user the ability to take a picture directly from

    your application.

    AddressChooserTask is used to launch the Contact application to select aparticular contacts physical address selected by the user to do some

    manipulations within the application from which this task is called.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.emailaddresschoosertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.savecontacttask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.saveemailaddresstask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.savephonenumbertask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.cameracapturetask_members(v=VS.92).aspxhttp://wsv000669/ccnet/server/local/project/TietoShopper/ViewProjectReport.aspxhttp://wsv000669/ccnet/server/local/project/TietoShopper/ViewProjectReport.aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.cameracapturetask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.savephonenumbertask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.saveemailaddresstask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.savecontacttask(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.emailaddresschoosertask_members(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    10/20

    Choosers

    PhoneNumberChooserTask allows your user to select a phone number fromtheir contacts to be used in your application.

    PhotoChooserTask allows your user to select a photo from their device to be

    used in your application.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.phonenumberchoosertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.photochoosertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.photochoosertask_members(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.phonenumberchoosertask_members(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    11/20

    Contacts API

    With Choosers, we were able to prompt a user to select a recordfrom their list of contacts on their phone, and retrieve a specificpiece of data from that contact: an email address or a phonenumber, but not both at once.

    With namespace

    Microsoft.Phone.UserData(introduced in WP 7.5), we have the ability to treat the userscontact list like a local database.

    We can search it, grab multiple contacts, and get their entirecontact record.

    Its important to remember that the data we are accessing is READ-ONLY.

    We cant make updates, delete anything, or even add anything.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    12/20

    Contacts API

    Searching for data method Contacts.SearchAsync methodtakes three parameters:

    stringthis is the search criteria youre using. In our example, its the

    contents of the TextBox that we created in our XAML file.

    FilterKindthis allows you to search only by PhoneNumber,

    DisplayName, or EmailAddress. If you select None, your searchcriteria string will be ignored.

    object this is an object parameter that you can use to pass data into

    the search so that when you receive the results, you know something

    about what you were trying to accomplish. This can be as simple as a

    string identifier, all the way up to a specific object that youll needlater.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    13/20

    Contacts API

    What you can get (assuming its available in the Contactrecord): Accounts the list of accounts that this contact is associated

    with. This includes things like Facebook, Windows Live, Outlook, etc.

    Addresses the list of addresses for this contact. Each address alsoincludes the account (from above) that it is associated with, the

    kind of address it is (like work, home, etc.), and finallyPhysicalAddress, which exposes all of the expected values likeAddress1, City, StateProvince, and CountryRegion.

    BirthdaysIm not sure why a user would have different birthdays,but each account might have a different value, so you get alist. Also, if a year isnt specified, youll get a value of 1 for the yearin those cases.

    Children a simple list of strings that represent the names of thechildren of the contact.

    Companies again enriched with the accounts data, this includesvalues like JobTitle, CompanyName, and OfficeLocation.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    14/20

    Contacts API CompleteName shown in our code sample above, this contains all the

    properties of a contacts name, including Title, Suffix, MiddleName, etc.

    DisplayName a simple string that represents the name that is used onthe phone for this contact.

    EmailAddressesa list of email addresses, with account and kinddata as well.

    IsPinnedToStart this is an interesting piece of boolean data, because it

    generally indicates which of this users contacts are the most importantto them (because the contact is pinned to the users start screen.)

    Notes a list of strings that the user has saved as notes about thiscontact.

    PhoneNumbers a list of all of the phone number associated with acontact, this is also decorated with accounts and kind data.

    SignificantOthersyoud like to think theres only one value for this aswell, butyou know Anyways, this is similar to the Children property. Alist of strings.

    Websites a list of the websites associated with this contact, stored asstrings.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    15/20

    Calendar API

    With same namespace

    Microsoft.Phone.UserData

    we have the ability to treat the calendar data like a local

    database.

    Its important to remember that the data we are accessing isas well READ-ONLY.

    We cant add new events to the users calendar, but we will be able to

    see when they are available.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    16/20

    Calendar API

    Searching for data method Appointments.SearchAsyncmethod takes three parameters:

    StartDate a DateTime value that indicates the beginning of our

    search. It is an inclusive value, so the time you indicate will also be

    included in the search.

    EndDate another inclusive value, it indicates the end time of oursearch.

    State a user-defined object that you can pass to the search, and it

    will be returned in the event handler, so that you can identify the

    individual search. Simple applications like the one in this article will

    likely use null for this value.

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    17/20

    Device InformationHardware

    Three HW buttons:Back, Start, and Search

    Display: 480x800, 3Dgraphics acceleration

    Camera: at least 5 megapixels, dedicatedcamera button

    Accelerometer Location with GPS

    and/or cellular location

    Memory: 256MB RAMor more, 8GB Flash ormore

    CPU: ARMv7Cortex/Scorpion orbetter (1Ghz)

    FM radio

    Vibration Push Notification

    (Compas)

  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    18/20

    Device Information

    Windows Phone devices meet a common hardwarespecification, but some provide additional features.

    It is possible for an application to examine the device'scapabilities in order to alter its behavior to provide the bestuser experience.

    WP SDK offers ability to retrieve information aboutcapabilities for: networking, hardware, and general deviceinformation such as manufacturer and firmware.

    We can use the DeviceStatus class from

    Microsoft.Phone.Info namespace, to retrieve deviceinformation.

    It is a static class that enables an application to obtaininformation about the device on which it is running.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus(v=vs.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus(v=vs.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    19/20

    Device Information

    It exposes the following static properties through whichyou can get different device information: ApplicationCurrentMemoryUsage: Returns the memory usage of the current

    application in bytes.

    ApplicationPeakMemoryUsage: Returns the peak memory usage of thecurrent application in bytes.

    DeviceFirmwareVersion :Returns the firmware version running on the device. DeviceHardwareVersion: Returns the hardware version running on the

    device.

    DeviceManufacturer: Returns the device manufacturer name.

    DeviceName: Returns the device name.

    DeviceTotalMemory: Returns the physical RAM size of the device in bytes.

    IsKeyboardDeployed: Indicates whether the user has deployed the physicalhardware keyboard of the device.

    IsKeyboardPresent: Indicates whether the device contains a physicalhardware keyboard.

    PowerSource: Indicates if the device is currently running on battery power oris plugged in to an external power supply.

    http://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.applicationcurrentmemoryusage(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.applicationpeakmemoryusage(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicefirmwareversion(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicehardwareversion(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicemanufacturer(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicename(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicetotalmemory(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.iskeyboarddeployed(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.iskeyboardpresent(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.powersource(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.powersource(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.iskeyboardpresent(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.iskeyboarddeployed(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicetotalmemory(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicename(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicemanufacturer(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicehardwareversion(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.devicefirmwareversion(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.applicationpeakmemoryusage(v=VS.92).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus.applicationcurrentmemoryusage(v=VS.92).aspx
  • 8/2/2019 WP7 Tpa 7 Choosers Launchers

    20/20

    Q & A

    ??