RVG
RVG

Reputation: 3576

How to clear Push notification alert on status bar - android

Hi i've used parse push notification in my android app.

i'm not using noraml notification. i've register parse push notification. The notification alert comes from server

device received the push notification successfully.

for example i've received 10 notification from server, if i open one notification on my device, the app has opened and the one notification has deleted.

My question is,

how to clear the other 9 push notification alert on status bar when open one notification..?

Upvotes: 4

Views: 3259

Answers (3)

Deshani Ranasingha
Deshani Ranasingha

Reputation: 508

Use this in your Main Activity

 NotificationManager nm = (NotificationManager) get SystemService(Context.NOTIFICATION_SERVICE);
    nm.cancelAll;

Upvotes: 0

Lakshmi Tulasi
Lakshmi Tulasi

Reputation: 1

Use this in your launch activity:

String ns = getActivity().NOTIFICATION_SERVICE;
NotificationManager nMgr = (NotificationManager) getActivity().getSystemService(ns);
nMgr.cancelAll();

Upvotes: 0

Thomas Bouldin
Thomas Bouldin

Reputation: 3725

Does android.app.NotificationManager.cancelAll() not work?

If you need to do something very custom, you can use ParsePush to launch an Intent rather than creating a Notification. You can then use a BroadcastReceiver to create Notifications with non-standard behavior (i.e. selective stacking, dismiss all when one is interacted with, etc).

Upvotes: 4

Related Questions