我希望在用戶點擊通知後關閉通知。我看到每個人都說使用標誌,但是我無法在任何地方找到標誌,因爲我使用的是NotificationCompat.Builder類而不是Notification類。有人有任何想法如何使她的自我消除通知?
下面是當我設置的通知我的代碼:點擊後刪除通知
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("New Question")
.setContentText("" + QuestionData.getAuthor().getUserName() + ": " + QuestionData.getQuestion() + "");
Intent openHomePageActivity = new Intent("com.example.ihelp.HOMEPAGEACTIVITY");
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntent(openHomePageActivity);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, mBuilder.build());
我在哪裏添加標誌?你可以在我的代碼中顯示我嗎? – 2013-02-27 19:49:40
將它添加到您的通知對象的通知標誌。 – JoxTraex 2013-02-27 19:54:19