Android-从RingtoneManager获取静音通知声音

时间:2018-07-07 20:12:44

标签: android notifications

我在从RingtonManager获取静音方面遇到问题。

这是我的代码:

private void selectNotificationTone(){
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getResources().getString(R.string.select_notif_tone));
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
    startActivityForResult(intent,NOTIF_TONE_CODE);
}

然后,显示所有通知/铃声的列表。当我选择任何音调时,就会以resultCode = -1(RESULT_OK)调用OnActivityResult()。

如果我选择“无”提示音,则onActivityResult()中接收到的Intent为null(如Android开发人员文档所述),但是resultCode为0(RESULT_FAIL)...与我选择“取消”选项一样。

如果选择了“无/静音”音调,或者用户选择了“取消”选项,有什么方法可以知道?

0 个答案:

没有答案