How to use the save ringtone task for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Use the save ringtone task to enable users to save an audio file to the system ringtones list. This task launches the Ringtones application, where the user saves the ringtone and can optionally set it as their default ringtone. Once the audio file is added to the list, the user can set it as the ringtone for individual contacts in the Contacts application.

By using Choosers, you help provide a consistent user experience throughout the Windows Phone platform. For more information, see Launchers and Choosers for Windows Phone 8.

Ringtone audio files must meet the following requirements.

  • Files must be of type M4R, MP3, or WMA.

  • Files must be less than 30 MB in size.

  • Files must not have digital rights management (DRM) protection.

To use the save ringtone task

  1. Add the following statement to your code.

    using Microsoft.Phone.Tasks;
    Imports Microsoft.Phone.Tasks
  2. Declare the task object. It must have page scope, so declare it in your page before the constructor.

    SaveRingtoneTask saveRingtoneChooser;
    Dim saveRingtoneChooser As SaveRingtoneTask
  3. Add the following code to your page constructor. This code initializes the task object, and identifies the method to run after the user completes the task.

    saveRingtoneChooser = new SaveRingtoneTask();
    saveRingtoneChooser.Completed += new EventHandler<TaskEventArgs>(saveRingtoneChooser_Completed);
    saveRingtoneChooser = new SaveRingtoneTask()
    AddHandler saveRingtoneChooser.Completed, AddressOf saveRingtoneChooser_Completed
  4. Add the following code to your application wherever you need it, such as in a button click event. To test this procedure, you can put the code in the page constructor. This is the code to launch the task.

    To test this code, you need to add an audio file to your application and name it myTone.wma. You can look for sample ringtones in C:\ProgramData\Microsoft\Windows\Ringtones, or search your computer for any short file with a .wma extension.

    saveRingtoneChooser.Source = new Uri("appdata:/myTone.wma");
    //saveRingtoneChooser.Source = new Uri("isostore:/myTone.wma"); 
    saveRingtoneChooser.DisplayName = "My custom ringtone";
    saveRingtoneChooser.Source = new Uri("appdata:/myTone.wma")
    'saveRingtoneChooser.Source = new Uri("isostore:/myTone.wma")
    saveRingtoneChooser.DisplayName = "My custom ringtone"


Use appdata: for audio files that are part of the application project. They are bundled into the XAP file and stored in the installation directory of the application. Use isostore: for audio files that are stored in isolated storage.

  1. Add the code for the completed event handler to your page. This code runs after the user completes the task. You can check to see whether the ringtone was saved successfully.

    void saveRingtoneChooser_Completed(object sender, TaskEventArgs e)
        switch (e.TaskResult)
            //Logic for when the ringtone was saved successfully
            case TaskResult.OK:
                MessageBox.Show("Ringtone saved.");
            //Logic for when the task was cancelled by the user
            case TaskResult.Cancel:
                MessageBox.Show("Save cancelled.");
            //Logic for when the ringtone could not be saved
            case TaskResult.None:
                MessageBox.Show("Ringtone could not be saved.");
    Private Sub saveRingtoneChooser_Completed(sender As Object, e As TaskEventArgs)
        Select Case e.TaskResult
            'Logic for when the ringtone was saved successfully
            Case TaskResult.OK
                MessageBox.Show("Ringtone saved.")
            'Logic for when the task was cancelled by the user
            Case TaskResult.Cancel
                MessageBox.Show("Save cancelled.")
            'Logic for when the ringtone could not be saved
            Case TaskResult.None
                MessageBox.Show("Ringtone could not be saved.")
        End Select
    End Sub

See Also




Other Resources

How to use the save contact task for Windows Phone 8