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

时间:2011-07-29 07:00:05

标签: android audio notifications

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

notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
Uri u = Uri.parse("android.resources://my.package.name/" + R.raw.customsound);
notification.sound = u;
对于媒体播放器来说,习惯性很好,但是在通知中它除了跟随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:准备失败:status = 0x1   07-29 12:44:36.396:DEBUG / MediaPlayer(61):无法在客户端打开文件,尝试服务器端   07-29 12:44:36.446:WARN / NotificationService(61):java.io.IOException:准备失败: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:准备失败:status = 0x1

1 个答案:

答案 0 :(得分:0)

试试这段代码

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