Android RingtoneManager wont work in API 23 and above.

怎甘沉沦 提交于 2019-12-25 05:23:45

问题


I have been trying to get the system's default notification sound to play using RingtoneManager. The code works fine until API 22 but just stops working beyond that.

This is how I am doing it,

Uri notificationTone = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION);
                    Ringtone r = RingtoneManager.getRingtone(context, notificationTone);
                    r.play();

What am I missing ? Any help would be appreciated.


回答1:


it's permission issue in >22, you need to request permission at runtime,

you can checked here



来源:https://stackoverflow.com/questions/43042705/android-ringtonemanager-wont-work-in-api-23-and-above

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!