有没有办法自定义 Android 铃声选择器对话框?
我使用以下代码显示一个用于选择本机铃声/文本铃声之一的对话框:
private void showTonePicker(int toneType, String pickerTitle) {
[...]
Intent Intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, toneType);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, pickerTitle);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, userTone.equals(TFSettings.SILENT_TONE_ID) ? null : Uri.parse(userTone));
startActivityForResult(intent, (toneType == RingtoneManager.TYPE_RINGTONE ? 1 : 2));
}
我这样调用上述方法:
- 用于选择文本铃声: showTonePicker(RingtoneManager.TYPE_NOTIFICATION, getString(R.string.texting_tone));
- 选择铃声: showTonePicker(RingtoneManager.TYPE_RINGTONE, getString(R.string.ringing_tone));
我有两个问题需要解决:
我必须显示小写按钮
在这两种情况下(即选择铃声和选择文本铃声时),本机 dialof 显示“默认铃声”。在选择文本提示音的情况下,我必须显示“默认文本提示音”(在本例中,toneType = RingtoneManager.TYPE_NOTIFICATION)。
有办法解决这些问题吗?我们可以自定义原生音调选择器吗?
感谢您提前的答复!
问候。
I show a dialog for selecting one of the native ring tones / text tones with the following code:
private void showTonePicker(int toneType, String pickerTitle) {
[...]
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, toneType);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, pickerTitle);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, userTone.equals(TFSettings.SILENT_TONE_ID) ? null : Uri.parse(userTone));
startActivityForResult(intent, (toneType == RingtoneManager.TYPE_RINGTONE ? 1 : 2));
}
I call the above method like this:
- for selecting text tone:
showTonePicker(RingtoneManager.TYPE_NOTIFICATION, getString(R.string.texting_tone)); - for selecting ring tone:
showTonePicker(RingtoneManager.TYPE_RINGTONE, getString(R.string.ringing_tone));
I have two problems to solve:
I must show lower cased buttons
In both cases (i.e. when selecting ring tone and also when selecting text tone), the native dialof shows "Default ringtone". I must display "Default text tone" in case of selecting a text tone (in this case toneType = RingtoneManager.TYPE_NOTIFICATION).
Is there a way to resolve these? Can we customize the native tone picker?
Thanks for the answers in advance!
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要设置默认铃声,您必须先设置 EXTRA_RINGTONE_EXISTING_URI。
To set default ringtone, you have to set EXTRA_RINGTONE_EXISTING_URI first.
不,抱歉,不适用于您所描述的物品。您需要为此构建自己的 UI。
No, sorry, not with respect to the items that you describe. You would need to build your own UI for this.
我不确定这是否可能。此外,不能保证 RingtonePreference 会打开系统的铃声选择器。用户可能安装了另一个应用程序,该应用程序具有 android.intent 的活动.action.RINGTONE_PICKER 在清单中声明的意图过滤器,他甚至可能将其作为默认的铃声选择器。
您可以实现自定义 RingtonePreference 和自定义 RingtonePickerActivity 并强制打开自定义铃声选择器,但可能会激怒用户。
如果我可以问的话,您出于什么原因想要更改它?
I'm not sure it's possible. Besides, there is no guarantee the RingtonePreference is going to open the System's ringtone picker. The user might have another app installed that has an activity with the android.intent.action.RINGTONE_PICKER intent filter declared in the manifest and he might even have it as the default Ringtone picker.
You might implement a custom RingtonePreference and a custom RingtonePickerActivity and force your custom Ringtone picker to be open but you might irritate your users.
If I may ask, for what reason would you like to change it anyway?