0

enter link description hereI create a custom layout for notification in android.I use remoteview for building notification and also add setOnClickPendingIntent() in some widgets of custom layout.But when user click on it the process in running but the notification setAutoCancel(true) not working.I attach some pics of my code.If anyone face this issue and resolve so you can help me.enter image description here

video link

1 Answer 1

0

you are calling startForeground, so you are running some Service and this Notification is it's graphic representation on the screen. setting setAutoCancel(true) won't work for such notification, as it will live as long as Service is. You have to stop this service by calling stopForeground(true) (e.g. in onDestroy), then your sticked-to-service notification will disappear

Sign up to request clarification or add additional context in comments.

8 Comments

but i need to use foreground service for represent the notification.I also stop the service when application terminate
so you can't dismiss this Notification. if you want a Notification, which will disappear after click - it can't be same, which is representing Service, so you have show another (using notificationManager.notify(ANOTHER_ID, notification)) or at least modify look of this Service-related one
i remove a notification using notificationManager.cancel(1).notification remove and i also stop the service but the notification panel does not dismiss
i attach a video in the question
i edit my question you can see
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.