5

ユーザーがボタンを押さずに通知をクリアできないようにする方法はありますか? 私はすでに setAutoCancel(false) を設定していますが、それは問題ありませんが、すべての通知をクリアするボタンがあり、通知をクリアしたくないため、ユーザーにとって重要であり、ユーザーはそれを読んでアクションを選択する必要があります。

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setSmallIcon(R.drawable.icon)
        .setContentTitle("Sync Failed")
        .setContentText("Lorem ipsum dolor sit amet")
        .setStyle(new NotificationCompat.BigTextStyle().bigText("Lorem ipsum dolor sit amet"))
        .addAction(R.drawable.change, "Change Pass", pChangePass)
        .addAction(R.drawable.remove, "Ignore", pIgnore)
        .setAutoCancel(false);


mNotificationManager.notify(accountUnique, builder.build());
4

2 に答える 2

21
.setOngoing(true) 

も追加する必要があります!

于 2013-10-17T13:11:57.307 に答える
1

そのためには、最後の 3 行のコードを次のように変更します。

final Notification notification = builder.build();
notification.flags = Notification.FLAG_NO_CLEAR;
mNotificationManager.notify(accountUnique, notification);
于 2013-10-17T13:11:56.907 に答える