Windows phone7 study note 11 -- starter and Selector

Source: Internet
Author: User

The execution model of the Windows Phone application determines that each application can only run in its own sandbox. He cannot directly access other storage information, such as the contact information, or directly call other functions, such as phone calls or photos.

In this way, if we want to call other functions or access other storage information, we need to use the starters and selectors, which provide applications with indirect methods to access these built-in functions.

Note that the operating system may terminate the current application when the initiator and Selector are running.

 

  1. Starter

The starter is equivalent to an android action that provides an action to direct to a specific place (functions such as sending text messages, opening webpages, and making phone calls ). Note that the starter starts a built-in function for the user, but does not return any data to the called program. Someone described the initiator as a "Trigger and forget" mechanism, which only triggers and does not give any data to the called program.

Common starters:

  • Emailcomposetask-Allow users to send emails through their email accounts.
  • Marketplacedetailtask-Start Windows Phone marketplace to allow users to view a specific product.
  • Marketplacehubtask-Start Windows Phone marketplace, which allows you to display a certain type of applications by default.
  • Marketplacereviewtask-Take the user to the comment page of the current program in Windows Phone marketplace.
  • Marketplacesearchtask-Start the Windows Phone marketplace search result. The result is from the search item you enter (or the one you set ).
  • Mediaplayerlauncher-Start the built-in media player and play the specified media file.
  • Phonecalltask-Start the phone program and display the phone number and name. The call is only made after the user clicks "call.
  • Searchtask-You can regard this as a way to provide Bing search functions in your program.
  • Smscomposetask-Start the Information Program and display the function of sending information to users. You can specify the message recipient and information content, but only the user can send the message.
  • Webbrowsertask-Open the web browser and jump to the specified URL.
The above are common starters. The names of each starter are linked to the corresponding section of msdn, where detailed examples are provided. If you want to see all the starters, you can go here to view: http://msdn.microsoft.com/zh-cn/library/ff769550 (V = vs.92). aspx. 2. SelectorThe selector is equivalent to the android URI. You can use this URI to return a string of data, which is the same in Windows Phone 7 applications, you can select some data from your mobile phone, such as the contact's phone number and an image in the photo album. The selector first starts a built-in program for the user to use, and then returns some data to the called program. When the user completes the operation, the calling program will be re-activated and receive the returned data. Note: The user may cancel the operation so that the returned data is null. Common selector:
  • Cameracapturetask-Provides users with the function of taking photos directly in the program.
  • Emailaddresschoosertask-In the program, you can select an email address from the contact.
  • Phonenumberchoosertask-In the program, you can select a phone number from the contact.
  • Photochoosertask-In the program, you can select a photo from the device.
Like the starter, each selector has a link, depending on all the selectors see: http://msdn.microsoft.com/zh-cn/library/ff769543 (V = vs.92). aspx. The usage of selector is more complex than that of the initiator. The general steps are as follows: (1) define the field of a chooser instance in the phoneapplicationpage class
(2) generate the chooser instance by using the phoneapplicationpage constructor, and register the completed event handler function (3) Implement the completed event handler function (4) Call show () the method of starting selector simulator does not support all starters and selectors. For details, see http://preview.library.microsoft.com/en-us/library/ff955600 (V = vs.92 ). aspx, I will not copy and paste it. 3. Running Mode of the starter and Simulator(1) When the initiator or selector is started, the application enters the inactive status page to trigger the onnavigatedfrom event, the app to trigger the deactived event, and the started built-in Program (task) takes over the current control. (2) When a task is running, the application may be tombstoned or not. When running some specific tasks, the application is not in Tombstone (I personally think it is the sleep mode in 7.1). After the call is completed, the parameters are passed to the instance of the original application. However, if you navigate to other applications while running the called task, the called program will still be called by tombstone. (3) there may be no tasks cameracapturetask for tombstone
Photochoosertask
Mediaplayelauncher
Emailaddresschoosertask
Phonenumberchoosertask
Phonecalltask (not even called for deactived events) (4) After the task is executed, the original application will be re-activated. If the program is not tombstoned, the original Instance is still running. The execution sequence is: the app will trigger the activated event; the page will trigger the onnavigatedto event.
If the application is Tombstone, a new instance is created. The execution sequence is: Call the application_activated () function; call the page constructor; and the completed event handler of the chooser; if it is reloaded, call the onnavigateto () function. (5) Difference between tombstone: whether to call the constructor of the app and page. Therefore, it is best not to place the program logic in the constructor, but in application_activated () and onnavigatedto () to restore the status information. To figure out the execution mode of the starter and selector, we need to first figure out the lifecycle and tombstone. The following article focuses on these points in general: http://www.coolxap.com/thread-12861-1-1.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.