如何使用RingtoneManager.ACTION_RINGTONE_PICKER设置铃声?
我尝试在这里找到解决方案,但只有自己/所选文件的解决方案,而当我调用选择器时没有代码的解决方案。当用户按下按钮时,我使用以下代码:
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);
这显示铃声选择器,用户可以选择想要的铃声,但我错过了两件事: - 打开时不显示当前铃声 - 单击“确定”时不会保存铃声
我仍然找不到如何使用已选择的当前铃声打开 RINGTONE_PICKER 的方法。有什么想法吗?
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);
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
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须实现
onActivityResult()
来接收用户选择的结果,然后保存它。这里有一个例子: http://www.ceveni .com/2009/07/ringtone-picker-in-android-with-intent.html
编辑:更新
您必须调用此:)
You must implement
onActivityResult()
to receive result from user's pick, then save it.Here an example: http://www.ceveni.com/2009/07/ringtone-picker-in-android-with-intent.html
EDIT: update
You must call this :)
“ringtone”是我在
onActivityResult()
中保存所选铃声的 uri。希望对您有帮助。如果确实如此,请点击回答。
"ringtone" is the uri in which I am saving the picked tone in
onActivityResult()
.Hope it helps you. Hit answered if it does.
该代码非常完美并且适合我。但你忘了提及所需的权限..就在这里。尝试这个代码..希望它有帮助
The code is perfect and works for me. But you forgot to mention the permissions required..here it is. try this code..hope it helps
此代码将显示用户在使用铃声选择器时之前设置的默认铃声。
在按钮中使用以下代码来获取铃声意图。
This code will show default ringtone which the user sets earlier when ringtone picker is used.
Use below code in the button for ringtone intent.