2011-07-29 124 views
0

我想在模拟器中播放通知声音,但它不工作; 我做的:模拟器通知声音问题

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

customsound与媒体播放器发挥出色,但在通知它给没什么除了以下的logcat:

12月7日至29日: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):无法在客户端打开文件,尝试服务器端 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) 12月7日至29日:03:34.712:WARN/AudioService(61):MediaPlayer的IOException异常:java.io.IOException的:准备失败:状态=为0x1

回答

0

尝试这个代码

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

感谢您的回答,但我已经尝试过这种方式,看起来似乎工作,再次在LogCat中的例外。 –