2011-07-29 48 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中的例外。 –