I’ve been doing Windows Phone development on and off for the past couple of years. In fact, I recently published the first version of my application “Snap Receipt” to the Windows Phone Marketplace. It’s an easy way to get receipts from your phone into Concur’s expense reporting system. You can check it out here. During my experiences with Windows Phone development I’ve identified 10 essential things developers need to know if they’re going to starting writing code against the platform. I thought I’d take some time to share them with you over a series of posts. Please note, these posts refer to Windows Phone 7.0/7.1. I have yet to see any developer bits for Windows Phone 8, but it is my hope that many of the principles I discuss in this series apply to the new platform as well.
In my last post in this series I discussed Launchers. In this post I’ll look at a feature called Choosers.
Much like launchers, chooser give applications the ability to launch one of the built-in, or native, Windows Phone applications. However, unlike launchers, choosers can return data from the built-in application to the calling application. Let’s say you’re building a photo editing application. You can use a chooser to launch the built-in photo picker application to allow the user to select which photo they want to edit. Once the user selects a photo, a stream representing the photo gets returned to the calling application which it can then use for whatever purpose you may have in mind.
Similarly to launchers, you can break choosers them out into three groups of functionality.
The first set has to do with pictures
- CameraCaptureTask allows you to take a picture using the phone’s camera.
- PhotoChooserTask allows you to select a picture that already exists on the phone.
The second set revolves around email addresses
- SaveEmailAddressTask allows you to save an email address to the phone’s contact list.
- EmailAddressChooserTask allows you to choose an email address from the phone’s contact list.
The last group deals with phone numbers
- SavePhoneNumberTask allows you to save a phone number to the phone’s contact list.
- PhoneNumberChooserTask allows you to choose a phone number from the phone’s contact
As with launchers, there are some behavioral differences you need to be aware when working with choosers in the emulator.
In the case of choosers, the only difference is with the CameraCaptureTask. Since the emulator does not have a camera, a default image is returned to your application.
Using a chooser in your Windows Phone application is a five step process:
- Create an instance of the task type for the Launcher.
- Identify the callback method to run after the user completes the task.
- Set any required and optional properties of the task object.
- Call the Show method of the task object.
- Implement the completed event handler to capture data and status after the user completes the task.
For detailed “How-To’s” of using specific choosers, you should check out this page on MSDN.
Previous posts in this series