點擊通知纔會消失,這是我通知代碼:機器人 - 如何讓用戶時,它
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.ic_launcher;
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, FistActiivty.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1,notification);
我怎樣才能讓用戶時,就可以點擊該通知只消失了,我的意思是我不想要當用戶點擊清除按鈕
感謝
您可以使其成爲持續通知。並實施通知的onClick,通過該通知清除相同的通知。 –