Divya SIngh
Divya SIngh

Reputation: 129

Clear push notification automatically after few minutes

I have developed parse push notification in my app.

What I want now push notification should clear automatically from notification bar without any click on it after 10 min.Is it possible?

Upvotes: 1

Views: 1278

Answers (3)

Artur Szymański
Artur Szymański

Reputation: 1648

Sure, implement any handler that will wait, and after it remove your notification.

Here is description how to remove notification.

Upvotes: 2

Akash Jindal
Akash Jindal

Reputation: 505

May be this will do the trick please do the required changes

Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
              String ns = Context.NOTIFICATION_SERVICE;
            NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(ns);
            nMgr.cancel(NOTIF_ID);
        }
    }, 600000);

Upvotes: 2

mr.icetea
mr.icetea

Reputation: 2647

Yes it is possible. Use Handler's postDelay to trigger Notification cancel after 10 min.

Upvotes: 0

Related Questions