Gaurav Agarwal
Gaurav Agarwal

Reputation: 19102

Notification do not dismiss till it clicked by the user

I am using the below code to generate the notification in my application

@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);
    }

Note:- I am using NotificationCompat2 by Jake Wharton.

Now this code works fine except when a new a Notification arrives it dismisses the old notification even if it is not read by the user.

My Question

How to show all the notification in the status slidingdrawer till it is not read by the user?

Upvotes: 0

Views: 146

Answers (1)

Kirill Rakhman
Kirill Rakhman

Reputation: 43861

A notification will be replaced by another if they have the same id. Change the id in

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

to display several notifications.

Upvotes: 5

Related Questions