2

I am developing an application that has a notification at some point. I implemented a couple of methods to make possible for the user to change the notification sound. How do I change the style of the Ringtone Picker Dialog?

This is my code for the ringtone picker:

public void getNotification(){
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
    this.startActivityForResult(intent, 5);
}

I already have a custom style for alert dialogues (R.style.AlertDialogCustom). How can I use this custom style in my ringtone picker dialog?

halfer
  • 19,824
  • 17
  • 99
  • 186
Marcos Guimaraes
  • 1,243
  • 4
  • 27
  • 50

1 Answers1

0

I managed to solve my problem by adding this line of code to the method above:

public void getNotification(){
        Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, R.style.AlertDialogCustom); //this one
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
        this.startActivityForResult(intent, 5);
    }

And this it the style corresponding to my custom AlertDialog:

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/maroon</item>
        <item name="colorAccent">@color/primary</item>
    </style>
Marcos Guimaraes
  • 1,243
  • 4
  • 27
  • 50
  • It didn't change anything in mine. You're passing EXTRA_RINGTONE_TYPE two times, right? One takes TYPE_NOTIFICATION and the other takes the style, correct? – bernardo.g Dec 11 '17 at 11:03
  • 2
    it will not work , [Android documentation](https://developer.android.com/reference/android/media/RingtoneManager#EXTRA_RINGTONE_TYPE) – Ali Alp Aug 16 '19 at 10:28