Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with notification sounds

I am trying to test a notification. I have created an emulator with audio playback enabled. I am able to get the notification but I am not able to hear sound. What could be the problem? Are there any settings I am missing?

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
        int icon = R.drawable.icon;
        CharSequence tickerText = "Hello";
        CharSequence contentTitle = "My notification";  // expanded message title
        CharSequence contentText = "Hello";      // expanded message text

        Intent notificationIntent = new Intent("ABC");
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        long when = System.currentTimeMillis();

        Notification notification = new Notification(icon, tickerText, when);

        notification.defaults |= Notification.DEFAULT_SOUND;

        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);


        mNotificationManager.notify(HELLO_ID, notification);

When I saw logcat, I have the following stack trace.

09-20 15:44:47.297: DEBUG/MediaPlayer(62): Couldn't open file on client side, trying server side
09-20 15:44:47.347: ERROR/MediaPlayerService(34): Couldn't open fd for content://settings/system/notification_sound
09-20 15:44:47.347: ERROR/MediaPlayer(62): Unable to to create media player
09-20 15:44:47.415: WARN/NotificationService(62): error loading sound for content://settings/system/notification_sound
09-20 15:44:47.415: WARN/NotificationService(62): java.io.IOException: setDataSource failed.: status=0x80000000
09-20 15:44:47.415: WARN/NotificationService(62):     at android.media.MediaPlayer.setDataSource(Native Method)
09-20 15:44:47.415: WARN/NotificationService(62):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:714)
09-20 15:44:47.415: WARN/NotificationService(62):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:669)
09-20 15:44:47.415: WARN/NotificationService(62):     at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:88)
like image 849
thisisananth Avatar asked Apr 07 '26 05:04

thisisananth


2 Answers

What thisisanath was thinking is correct. After reading another person's problems, I added the indicated directory structure and pushed a sound file to the /mnt/sdcard/media/audio/notifications directory in DDMS. (I think C:\Program Files (x86)\Android\android-sdk\platforms\android-14\data\res\raw\fallbackring.ogg makes a good notification sound.) In the emulator I then unmounted and then remounted the SD card. The notification ringtone setting then had "Cobalt" in addition to "Silent", and after selecting that, my notification sounds worked fine.

like image 160
Garret Wilson Avatar answered Apr 08 '26 20:04

Garret Wilson


I was able to get the notification sound play by giving it a different file on the sdcard. I was having a problem playing the default sound. I am not sure what the default sound is. When I went into settings and saw the default sound - it was having only one option i.e silent. I was not able to change it also. So may be there is no default notification sound and hence I was getting that error, though we would assume, there would be a sensible default.

like image 41
thisisananth Avatar answered Apr 08 '26 21:04

thisisananth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!