cancel foreground notification without stopping service as the service displays multiple notifications

Viewed 294

i have download service that i display multiple notifications by it i make the service always foreground to make it not killed each notification i display has custom remoteview that has cancel button

I want to make download service acts like what Google chrome download service does which has pause and cancel button in each notification

i display each notification by

        startForeground(1, notification1);
        startForeground(2, notification2);
        startForeground(3, notification3);

i want for example when i click on cancel button in notification2 i cancel this notification i.e remove it from notification bar without stopping the service as the service is used to display the other notifications 1,3

            notificationmanager.cancel(2) 

doesn't work as it is displayed by startforeground

and also i want also to stop the service only when i click on cancel button on any notification if there is no other notifications in the notification bar

0 Answers
Related