我可以成功调出一个铃声选择器并使用以下代码获得结果uri ...
selsound_button.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
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_ALARM);
startActivityForResult( intent, 999);
}
});
...但我未能弄清楚如何执行以下操作:
鉴于我已经知道当前的uri,我希望告诉选择器当前选择此项,以便它可以突出显示正确的单选按钮。目前,在我按下其中一个之前,根本没有选择任何无线电按钮。
答案 0 :(得分:23)
您需要添加
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
设置单选按钮
答案 1 :(得分:9)
这是您的确切代码。
selsound_button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
final Uri currentTone= RingtoneManager.getActualDefaultRingtoneUri(YourActivity.this, RingtoneManager.TYPE_ALARM);
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentTone);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
startActivityForResult(intent, TONE_PICKER);
}
});