如何使用 RingtoneManager.ACTION_RINGTONE_PICKER 设置铃声? [英] How to set ringtone with RingtoneManager.ACTION_RINGTONE_PICKER?

查看:21
本文介绍了如何使用 RingtoneManager.ACTION_RINGTONE_PICKER 设置铃声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在这里找到解决方案,但只有自己/选择的文件的解决方案,而不是我调用选择器时的代码.当用户按下按钮时,我使用以下代码:

I try to find solution here, but there are only solution for own/selected file, not for code when I call picker. I use following code when user press button:

Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
ActivityCurrent.this.startActivityForResult(intent,999);

这个显示铃声选择器,用户可以选择想要的铃声,但我错过了两件事:- 打开时不显示当前铃声- 点击确定时不保存铃声

This show ringtone picker, user can choose what ringtone wants, but I miss two things: - it doesn´t show current ringtone when it open - it not save ringtone when it is clicked on OK

我仍然无法找到如何使用已选择的当前铃声打开 RINGTONE_PICKER.有什么想法吗?

I still can´t find way how to open RINGTONE_PICKER with already selected current ring tone. Any idea?

Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
ActivityCurrent.this.startActivityForResult(intent,999);

推荐答案

你必须实现onActivityResult()来接收用户选择的结果,然后保存.

You must implement onActivityResult() to receive result from user's pick, then save it.

if (resultCode == RESULT_OK) {
    Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
    if (uri != null) {
    String ringTonePath = uri.toString();
}

这里是一个例子:http://www.ceveni.com/2009/07/ringtone-picker-in-android-with-intent.html

更新

RingtoneManager.setActualDefaultRingtoneUri(
    myActivity,
    RingtoneManager.TYPE_RINGTONE,
    uri);

你必须这样称呼它:)

这篇关于如何使用 RingtoneManager.ACTION_RINGTONE_PICKER 设置铃声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆