我想在模拟器中播放通知声音,但无法正常工作;
我做:
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/