Pergunta

Na minha aplicação, eu estou usando GCM serviços.Eu quero beep ou jogar um pequeno arquivo mp3 em onMessage função.

Meu GCMIntentService é estendida a partir de GCMBaseIntentService.

Alguém pode por favor, compartilhe o código ou sugerir-me como conseguir isso.

Obrigado

Foi útil?

Solução

Você poderia usar:

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top