0
我將GCM服務器的通知推送給所有客戶端。 連續聽到聲音並震動,直到我拉下通知欄。GCM Android - 收到通知時不斷聽到聲音並震動
這裏是我的代碼:
private static void generateNotification(Context coNtext, Bundle data)
{
int icon = R.drawable.launcher;
long when = System.currentTimeMillis();
NotificationManager nm = (NotificationManager) coNtext.getSystemService(Context.NOTIFICATION_SERVICE);
Intent ni = new Intent(coNtext, MainActivity.class);
ni.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(coNtext, 0, ni, PendingIntent.FLAG_UPDATE_CURRENT);
Notification noti = new NotificationCompat.Builder(coNtext)
.setContentTitle(coNtext.getString(R.string.app_name))
.setContentText(data.getString("message"))
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_ALL)
.setSmallIcon(icon)
.setWhen(when)
.build();
noti.flags = Notification.FLAG_AUTO_CANCEL;
nm.notify(0, noti);
}
我只想讓它正常(聲音和振動只有1次)。
如何解決?
謝謝。
太棒了。謝謝。你救了我的命。 – user3789802