我尝试保存所选择的铃声:
setSoundBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
startActivityForResult(intent, 5);
tmp = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
}
});
Tmp是Uri
,当我创建通知时,我会调用
.setSound(tmp)
实际上这不起作用,但当我将其更改为:
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
我能听到声音。 也许有人可以帮我解决这个问题。
答案 0 :(得分:1)
你的代码是写的但是为了获得所选择的铃声,你必须在你的活动中实现onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 5:
tmp = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
break;
default:
break;
}
}
}