Change ringtone picker dialog style

。_饼干妹妹 提交于 2019-12-24 03:30:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!