2010-09-20 3 views
3

J'essaie de tester une notification. J'ai créé un émulateur avec la lecture audio activée. Je suis en mesure d'obtenir la notification, mais je ne suis pas en mesure d'entendre le son. Quel pourrait être le problème? Y a-t-il des paramètres qui me manquent?Problème avec les sons de notification

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); 

Lorsque j'ai vu logcat, j'ai la trace de pile suivante.

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) 

Répondre

6

Ce que pensait thisisanath est correct. Après avoir lu another person's problems, j'ai ajouté la structure de répertoire indiquée et poussé un fichier son dans le répertoire /mnt/sdcard/media/audio/notifications dans DDMS. (Je pense que C:\Program Files (x86)\Android\android-sdk\platforms\android-14\data\res\raw\fallbackring.ogg fait un bon son de notification.) Dans l'émulateur j'ai alors démonté, puis remonté la carte SD. Le réglage de la sonnerie de notification a alors eu "Cobalt" en plus de "Silencieux", et après avoir sélectionné cela, ma notification a bien fonctionné.

4

J'ai été en mesure d'obtenir la notification sonore en lui donnant un fichier différent sur la carte SD. J'avais un problème en jouant le son par défaut. Je ne suis pas sûr du son par défaut. Quand je suis allé dans les paramètres et vu le son par défaut - il n'y avait qu'une seule option, c'est silencieux. Je n'étais pas capable de le changer aussi. Donc peut-être il n'y a pas de son de notification par défaut et par conséquent je recevais cette erreur, mais nous supposerions, il y aurait un défaut par défaut.