0

それぞれに異なるバンドル/アクティビティが関連付けられているさまざまな通知があります。私の問題は、クリックしても消えないことです。ただし、それらは継続的な通知の対象ではなく、「クリア」するとそれらが削除されます。以下は私のコードです。どんな考えでも大歓迎です。:)

 private void showNotification(Bundle b){
    CharSequence myText = b.getString("notifStr");

    Notification notification = new Notification(R.drawable.stat_sample, myText,System.currentTimeMillis());

    Intent i = new Intent(myContext, NewPlace.class);
    i.setAction(Intent.ACTION_VIEW + Integer.toString(b.getInt("id")));
    i.putExtras(b);

    PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0, i, 0);

    notification.defaults |= Notification.FLAG_AUTO_CANCEL;

    notification.setLatestEventInfo(myContext, myText,myText, contentIntent);

    notifMan.notify(b.getInt("id"), notification);
}
4

2 に答える 2

2

変更してみてください:

notification.defaults |= Notification.FLAG_AUTO_CANCEL;

notification.flags |= Notification.FLAG_AUTO_CANCEL;

通知文書 (フラグ)

public int のデフォルト

導入されたバージョン: API レベル 1 デフォルトから取得する値を指定します。設定するには、または DEFAULT_SOUND、DEFAULT_VIBRATE、DEFAULT_LIGHTS から必要なものを選択します。すべてのデフォルト値については、DEFAULT_ALL を使用してください。

于 2011-04-15T17:40:20.860 に答える
1

試してみてください

notification.flags |= Notification.FLAG_AUTO_CANCEL;
于 2011-04-15T17:46:03.063 に答える