Question

Dans ma candidature, j'utilise GCM Services.Je veux bip ou jouer un petit fichier MP3 à la fonction OnMessage.

Mon GCMintTaleService est étendu de GCMBaseintService.

Quelqu'un peut-il partager le code ou me suggérer comment y parvenir.

merci

Était-ce utile?

La solution

vous pouvez utiliser:

Notification notification = new Notification(icon, title, when);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND; // To play default notification sound
notification.sound = Uri.parse("PATH_TO_YOUR_SOUND_FILE"); // to play custom notification sound
NotificationManager nm = (NotificationManager)   getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(System.currentTimeMillis(), notification);

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top