有没有办法自定义 Android 铃声选择器对话框?

发布于 2024-12-29 02:06:56 字数 1188 浏览 1 评论 0原文

我使用以下代码显示一个用于选择本机铃声/文本铃声之一的对话框:

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

我有两个问题需要解决:

  1. 我必须显示小写按钮

  2. 在这两种情况下(即选择铃声和选择文本铃声时),本机 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:

  1. I must show lower cased buttons

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

过气美图社 2025-01-05 02:06:56

要设置默认铃声,您必须先设置 EXTRA_RINGTONE_EXISTING_URI。

intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneUri);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, ringtoneUri);

To set default ringtone, you have to set EXTRA_RINGTONE_EXISTING_URI first.

intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneUri);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, ringtoneUri);
只是在用心讲痛 2025-01-05 02:06:56

我们可以自定义原生音调选择器吗?

不,抱歉,不适用于您所描述的物品。您需要为此构建自己的 UI。

Can we customize the native tone picker?

No, sorry, not with respect to the items that you describe. You would need to build your own UI for this.

放肆 2025-01-05 02:06:56

我不确定这是否可能。此外,不能保证 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文