推送通知的一些問題。當我按下其中一個應用程序時,如何解除我的應用程序的所有通知?另外...如果我啓動應用程序(不是來自通知),我如何解除通知?關閉Android推送通知
下面是我如何從我的GcmIntentService類發送通知(如果它是有用的)。
private void sendNotification(Bundle extras) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
NOTIFICATION_ID = Integer.parseInt(extras.getString("id"));
Intent in = new Intent(this, PushActivity.class);
in.putExtras(extras);
in.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
String msg = extras.getString("msj");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
in, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("MY TITLE")
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
嘗試'mBuilder.cancelAll()' –
mBuiler不允許我做.cancelAll();任何想法? –
爲什麼?去官方[文檔](http://developer.android.com/guide/topics/ui/notifiers/notifications.html) –