Address Chooser Task in Windows Phone

Windows Phone SDK provides the chooser “AddressChooserTask” that enables the users to retreive the physical address of the selected contact .

To use the Address Chooser Task in Windows Phone , follow the below steps

1. Add the namespace Microsoft.Phone.Tasks

2. Create an instance of the AddressChooserTask . Make sure that you declare the AddressChooserTask in the page scope and then add the event handler to the Completed property of the AddressChooserTask .

AddressChooserTask addressSelect;
addressSelect = new AddressChooserTask();
addressSelect.Completed += new EventHandler(addressSelect_Completed);

3. Call the Show method of the AddressChooserTask

addressSelect.Show();

4. This will launch the Contacts application where the user can select a contact , then the event “Completed” is raised which receives the address .

public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
AddressChooserTask addressSelect;
private void button1_Click(object sender, RoutedEventArgs e)
{
addressSelect = new AddressChooserTask();
addressSelect.Completed += new EventHandler(addressSelect_Completed);
addressSelect.Show();
}
void addressSelect_Completed(object sender, AddressResult e)
{
if (e.TaskResult == TaskResult.OK)
{
textBox1.Text = e.Address;
}
}
}

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...