gcmintentService onMessageが発砲したときにサウンドファイルを再生する方法?
-
11-12-2019 - |
質問
私のアプリケーションではGCMサービスを使用しています。OnMessage関数でビープ音やプレイしたいです。
私の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);
. 所属していません StackOverflow