如何使用 RingtoneManager.ACTION_RINGTONE_PICKER 设置铃声?

How to set ringtone with RingtoneManager.ACTION_RINGTONE_PICKER?(如何使用 RingtoneManager.ACTION_RINGTONE_PICKER 设置铃声?)
本文介绍了如何使用 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 设置铃声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
appearance().setBackgroundImage Not Working On Custom Class(外观().setBackoundImage在自定义类上不起作用)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)