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

2023-07-08移动开发问题
2

本文介绍了如何使用 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 doesnt show current ringtone when it open - it not save ringtone when it is clicked on OK

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

I still cant 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 设置铃声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

cocos2D iPhone中的UItextfield文本对齐问题
UItextfield text alignment issue in cocos2D iPhone(cocos2D iPhone中的UItextfield文本对齐问题)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?
How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)...
2024-08-12 移动开发问题
5