Android Notification not getting dismissed on click/swipe
android, android-notifications
Solution
I found the answer from a answer to my other post. Basically there can be only one foreground service. Using startForeground() to generate the notification means that as long as this service is running the notification cannot be removed.
Instead using NotificationManager.notify() simply generates the notification. Setting AutoCancel(true) for this notification makes it disappear on swipe/click.
Thanks!
Problem
I am creating notification from a intent service using startForeground(id,notification). ``` Random r=new Random(); int id=r.nextInt(9999); Builder notice2=new Notification.Builder(getApplicationContext()) .setContentTitle(call.getName()) .setAutoCancel(true) .setContentIntent(intent) .setContentText("content") .setSmallIcon(com.project.calltracker.R.drawable.ic_alert) .setLargeIcon(BitmapFactory.decodeResource(getResources(), com.project.calltracker.R.drawable.ic_logo)); startForeground(id, notice2.getNotification()); ``` Here I have set AutoCancel(true) But when I click on the notification it does not disappear?? I am really confused. I have tried everything for last couple hours but still no luck! Please help! Thanks!