【Notification】.flags += Notification.FLAG_ONGOING_EVENT;
【Notification】.flags += Notification.FLAG_NO_CLEAR;では、このクリアされなノーティフィケーションは、どうやって消せばいいのでしょうか。これは、NotificationManagerの「cancel」メソッドを用います。これを使い、引数にノーティフィケーションに割り当てたIDを指定してキャンセルします。
【NotificationManager】.cancel( ノーティフィケーションID );
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※表示を更新する public class MySampleActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } private int counter = 1; private Notification notify = null; private PendingIntent pending = null; public void doAction(View view){ if (notify == null){ Intent intent = new Intent(this,jp.tuyano.sample.MySampleActivity.class); pending = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notify = new Notification(); } notify.flags = Notification.FLAG_AUTO_CANCEL; notify.icon = R.drawable.icon; notify.number = counter++; notify.setLatestEventInfo(this, "TEST INFO", "テストのノーティフィケーションです。", pending); NotificationManager manager = (NotificationManager)this. getSystemService(Activity.NOTIFICATION_SERVICE); manager.notify(0, notify); } }
<< 前へ | 次へ >> |