Android RingtoneManager无法在API 23及更高版本中使用. [英] Android RingtoneManager wont work in API 23 and above.

查看:640
本文介绍了Android RingtoneManager无法在API 23及更高版本中使用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用RingtoneManager播放系统的默认通知声音.该代码在API 22之前可以正常工作,但仅在此之后才能停止工作.

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.

这就是我的做法

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.

推荐答案

这是> 22中的权限问题,您需要在运行时请求权限,

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

您可以在此处进行检查

这篇关于Android RingtoneManager无法在API 23及更高版本中使用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆