質問

私のアプリケーションでは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);
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top