3

私のアプリケーションでは、ビデオのアップロード中に進行中の通知を表示しています。アップロード後に通知をクリアしたい。いろいろ調べたのですが、明確な答えが得られません。

4

3 に答える 3

5

Androidドキュメントの通知の管理から:

また、cancel(int) を使用して手動でクリアするか、通知 ID を渡すか、cancelAll() を使用してすべての通知をクリアすることもできます。

したがって、通知を非表示にするには、次を実行する必要があります。

mNotificationManager.cancel(notification_id);

ここで、mNotificationManagerNotificationManagerオブジェクトで、notification_idはオブジェクトにint渡される通知の識別子ですNotificationManager

mNotificationManager.notify(notification_id, notification);
于 2012-05-21T12:43:16.697 に答える
2

これが Notification.Builder でどのように行われるかを示すために、次のように FLAG_AUTO_CANCEL を設定できます。

Notification.Builder mBuilder = new Notification.Builder(getContext())
                    .setSmallIcon(R.drawable.icon)
                    .setContentTitle("My notification")
                    .setContentText("Hello Notify!")
                    .setOngoing(true)
                    .setAutoCancel(true);
于 2015-06-12T18:16:33.940 に答える
1

通知をクリックすると、通知をクリアできます..!!

Notification notification = new Notification("必要なデータ..");

notification.flags |= Notification.FLAG_AUTO_CANCEL;

于 2012-05-21T12:50:38.917 に答える