Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通知在Android中不播放声音_Android_Notifications - Fatal编程技术网

通知在Android中不播放声音

通知在Android中不播放声音,android,notifications,Android,Notifications,我在安卓系统中有一个通知,效果很好,但它不能播放我指定的声音: notification.sound = Uri.parse("android.resource://com.example.code/raw/sound"); 我知道我可能不是第一个遇到这个问题的人,但是我浏览的所有关于这个问题的帖子都没有帮到我 谢谢。有声音播放吗 确保不要在notification.DEFAULT上设置默认声音,否则默认声音将覆盖您的自定义声音 此外,请尝试使用其他Uri格式,如: notification.

我在安卓系统中有一个通知,效果很好,但它不能播放我指定的声音:

notification.sound = Uri.parse("android.resource://com.example.code/raw/sound");
我知道我可能不是第一个遇到这个问题的人,但是我浏览的所有关于这个问题的帖子都没有帮到我

谢谢。

有声音播放吗

确保不要在notification.DEFAULT上设置默认声音,否则默认声音将覆盖您的自定义声音

此外,请尝试使用其他Uri格式,如:

notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sound );

请确保将您的
sound.mp3
文件放在您的
/res/raw/
文件夹中。

我的操作与您的建议完全相同,我的声音文件放在/res/raw中,但我总是有问题!!好的,打开你的sound.mp3文件,检查它是否真的可以被播放器复制。我打开了,我用VLC media player打开了它,它正常播放,没有问题,它有mp3扩展名和71.9 kB的sizeNo,没有播放声音,我没有将声音设置为默认值,我使用了不同的Uri格式,包括你的建议,但我总是没有声音播放!!所以我猜这件事从来没有解决过,那是2020年的5年
Notification.Builder mBuilder = new Notification.Builder(this)
mBuilder.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sound));