如果通知有问题,我想显示在通知栏中。尽管我将通知标记设置为Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL
,单击通知后通知不会消失。有什么想法我做错了吗?
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);
mNotificationManager.notify(1,notification);
和NotificationBuilder 创建通知有什么区别mNotificationManager.notify(1, mBuilder.build());
?谢谢。