私のアプリケーションでは、GCM サービスを使用しています。onMessage関数でビープ音を鳴らしたり、小さなmp3ファイルを再生したりしたいです。
私の GCMIntentService は GCMBaseIntentService から拡張されています。
誰かがコードを共有するか、これを達成する方法を提案してください。
ありがとう
私のアプリケーションでは、GCM サービスを使用しています。onMessage関数でビープ音を鳴らしたり、小さなmp3ファイルを再生したりしたいです。
私の GCMIntentService は GCMBaseIntentService から拡張されています。
誰かがコードを共有するか、これを達成する方法を提案してください。
ありがとう
あなたが使用することができます:
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);