intent,PendingIntent.FLAG_CANCEL_CURRENT);
notificationBuilder.setContentIntent(pendingIntent2);
这里的PendingIntent表示的是就是启动APP,而FLAG_CANCEL_CURRENT表示相应的PendingIntent已经存在,则取消前者,然后创建新的PendingIntent。
1) 设置铃声和震动只执行一次
Notificationnotification=builder.build();
notification.flags=Notification.FLAG_ONLY_ALERT_ONCE;
这里的Notification.FLAG_ONLY_ALERT_ONCE就是表示的铃声和震动只执行一次。