问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/41572949/change-ringtone-picker-dialog-style