[android]通知バーに実行中として通知する

hidaka

2009/09/11

TAG
android

NotificationManagerで通知領域に情報を出すことができますが、そのままですと
通知を消去で消せてしまい、実行中のactivityに遷移させようとしていた時などに
遷移できなくなってしまいます。
以下が通知するだけのコード。

mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notification = new Notification(R.drawable.icon, notiStr, System.currentTimeMillis());
contentIntent = PendingIntent.getActivity(this, 0, new Intent(this,raceMap.class),
Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(this, getString(R.string.app_name),getString(R.string.nm1), contentIntent);
mNM.notify(notificationId, notification);

ここに以下の1行を追加して、上段の実行中のアプリに登録することができます。

notification.flags= Notification.FLAG_ONGOING_EVENT;

コメントを投稿する

トラックバック (0)

トラックバックURL: http://kiteretsu.kayac.com/cgi-bin/mt-tb.cgi/40