Android 在用户单击通知之前,不要关闭通知

Android 在用户单击通知之前,不要关闭通知,android,android-notifications,Android,Android Notifications,我正在使用下面的代码在我的应用程序中生成通知 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = MainActivity.this; notifManager = (Notific

我正在使用下面的代码在我的应用程序中生成通知

@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = MainActivity.this;

        notifManager = (NotificationManager) mContext.getSystemService(mContext.NOTIFICATION_SERVICE);

        mNotification = new NotificationCompat2.Builder(mContext).setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setTicker("Launch download").setContentTitle("Downloader").setContentText(content)
                .setContentIntent(getPendingIntent());

        mNotification.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
        mNotification.setAutoCancel(true); 
        notifManager.notify(UPDATE_PROGRESS, mNotification.build());


    }

    private PendingIntent getPendingIntent() {

        Intent i = new Intent(mContext, NotificationReceiver.class);
        //i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
        return PendingIntent.getActivity(mContext, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
    }
注:-我使用的是杰克·沃顿

现在,这段代码工作正常,除非当新的a通知到达时,即使用户没有读取旧的通知,它也会将其取消

我的问题


如何在状态滑动抽屉中显示所有通知,直到用户无法读取为止?

如果通知具有相同的id,则通知将替换为另一个通知。请在中更改id

notifManager.notify(id, mNotification.build());

显示多个通知。

如果通知具有相同的id,则通知将被另一个通知替换。请在中更改id

notifManager.notify(id, mNotification.build());
显示多个通知