gpt4 book ai didi

android - 模拟器中通知中的声音问题

转载 作者:行者123 更新时间:2023-12-03 02:24:38 26 4
gpt4 key购买 nike

我想在模拟器中播放通知声音,但无法正常工作;
我做:

notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
Uri u = Uri.parse("android.resources://my.package.name/" + R.raw.customsound);
notification.sound = u;

可以在mediaplayer上很好地播放customestound,但在通知中,它仅显示以下LogCat内容:

07-29 12:44:36.326: INFO/StagefrightPlayer(34): setDataSource('/system/media/audio/ui/Effect_Tick.ogg') 07-29 12:44:36.396: WARN/AudioService(61): MediaPlayer IOException: java.io.IOException: Prepare failed.: status=0x1 07-29 12:44:36.396: DEBUG/MediaPlayer(61): Couldn't open file on client side, trying server side 07-29 12:44:36.446: WARN/NotificationService(61): java.io.IOException: Prepare failed.: status=0x1 07-29 12:44:36.446: WARN/NotificationService(61): at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90) 07-29 12:03:34.712: WARN/AudioService(61): MediaPlayer IOException: java.io.IOException: Prepare failed.: status=0x1

最佳答案

试试这个代码

notification.sound =Uri.parse("android.resource://" + getPackageName() + "Name OF audio store in raw folder");

关于android - 模拟器中通知中的声音问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6869681/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com