Nếu có một số vấn đề với thông báo tôi muốn hiển thị trên thanh thông báo. Mặc dù tôi đặt cờ thông báo thành Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL
thông báo sẽ không biến mất sau khi nhấp vào. Bất kỳ ý tưởng những gì tôi đang làm sai?Thông báo của Android không biến mất sau khi nhấp vào thông báo
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.icon;
CharSequence tickerText = "Ticker Text";
long time = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, time);
notification.flags = Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL;
Context context = getApplicationContext();
CharSequence contentTitle = "Title";
CharSequence contentText = "Text";
Intent notificationIntent = new Intent(this, SilentFlipConfiguration.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1,notification);
Cảm ơn rất nhiều. Nó làm việc cho tôi – Sakthimuthiah
Vì vậy, những gì khác biệt tạo ra thông báo bằng cách sử dụng Notification 'mNotificationManager.notify (1, thông báo);' và sử dụng NotificationBuilder 'mNotificationManager.notify (1, mBuilder.build());'? Cảm ơn. – NPE
Câu trả lời này phải được chấp nhận, nó phù hợp hơn với học thuyết thiết kế Android hiện tại – jmaculate