我瀏覽過Stackoverflow並看到這個問題已被詢問,但我沒有找到任何解決方案。如何在通知按鈕點擊後關閉狀態欄/通知面板
我有2個按鈕的自定義通知。我想按下該通知上的按鈕後關閉狀態欄面板,但不知道如何。如果我按通知本身(所以contentIntent),然後面板關閉,這也是我想要的按鈕。
這裏是我的通知碼:
Notification notification = new Notification(R.drawable.icon, "Service running", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.contentIntent = openIntent;
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_layout);
contentView.setOnClickPendingIntent(R.id.button1, stopIntent);
contentView.setOnClickPendingIntent(R.id.button2, addIntent);
notification.contentView = contentView;
notificationManager.notify(NOTIFICATION_ID, notification);
http://stackoverflow.com/a/6435373/115145按鈕的支持,這是你的'minSdkVersion',等你應該沒問題,但我不知道如何關閉抽屜。我對我的錯誤表示歉意 - 我忘記了他們正式開始支持這一點。 – CommonsWare 2013-03-22 13:03:10
Np,也許我應該提前一點說我的minSdkVersion = 11 ;-) – 2013-03-22 13:17:30