2013-10-17 7 views
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()); 

答えて

14
.setOngoing(true) 

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

1

このようなあなたの最後の3行のコードを変更...

final Notification notification = builder.build(); 
notification.flags = Notification.FLAG_NO_CLEAR; 
mNotificationManager.notify(accountUnique, notification); 
関連する問題