3

私のアプリケーションでは、GCM サービスを使用しています。onMessage関数でビープ音を鳴らしたり、小さなmp3ファイルを再生したりしたいです。

私の GCMIntentService は GCMBaseIntentService から拡張されています。

誰かがコードを共有するか、これを達成する方法を提案してください。

ありがとう

4

1 に答える 1

6

あなたが使用することができます:

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);
于 2012-09-30T20:32:54.487 に答える