【发布时间】:2014-03-21 11:06:08
【问题描述】:
我正在尝试从我的应用程序中更改通知铃声。到目前为止,我可以显示通知铃声,然后选择其中一个,但它并没有改变它。这是我目前使用的:
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
Uri notification = Uri.parse(settings.getString("timerSound", RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString()));
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Alert Tone");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, notification);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
startActivityForResult(intent, 5);
【问题讨论】:
-
您需要覆盖onActivityResult并将选中的铃声设置为通知铃声。
-
这个链接可能对你有帮助stackoverflow.com/questions/1271777/…
标签: android notifications ringtone