Reputation: 5166
i wanna play notification sound in emulator, but it is not working; i do:
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
Uri u = Uri.parse("android.resources://my.package.name/" + R.raw.customsound);
notification.sound = u;
customsound is played well with mediaplayer, but in notification it gives nothing except following 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
Upvotes: 0
Views: 1396
Reputation: 2250
try this code
notification.sound =Uri.parse("android.resource://" + getPackageName() + "Name OF audio store in raw folder");
Upvotes: 0