问题
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