【问题标题】:Change ringtone picker dialog style更改铃声选择器对话框样式
【发布时间】:2017-05-25 04:27:28
【问题描述】:

我正在开发一个在某个时间点有通知的应用程序。我实现了几种方法来使用户可以更改通知声音。如何更改铃声选择器对话框的样式?

这是我的铃声选择器代码:

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);
}

我已经有一个自定义样式用于警报对话 (R.style.AlertDialogCustom)。如何在我的铃声选择器对话框中使用这种自定义样式?

【问题讨论】:

  • 我也想知道。你找到解决办法了吗?
  • 其实我做到了。我刚刚回答了我自己的问题。

标签: android notifications ringtonemanager


【解决方案1】:

我设法通过将这行代码添加到上述方法中来解决我的问题:

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);
    }

这是与我的自定义 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>

【讨论】:

  • 它并没有改变我的任何东西。你通过 EXTRA_RINGTONE_TYPE 两次,对吧?一个采用 TYPE_NOTIFICATION,另一个采用样式,对吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-15
  • 1970-01-01
相关资源
最近更新 更多