If you wonder why even after calling setAutoCancel(true) after you instantiate Notification.Builder and tapping on the notification it still stays put in the notification area, you did nothing wrong.

You just lacked something for sure. The thing is, you have to set an Intent so that when you tap on the notification, it will execute that Intent. The setAutoCancel(true) will then work and hide the notification.

Here is a sample code that will just hide the notification and does nothing else.


Ever wanted to create an icon from an ImageView with a notification alert badge like in the image below? In Android, there is no shortcut in implementing this. I wish there is one but no such luck.

You have to do it on your own. Luckily, the layout system is pretty handy. I made it work with the XML code below.

The TextView will contain both the total count and the image badge. It is actually quite easy, if you know how to use RelativeLayout. I hope this helps.

This should let you feature ImageView icons with alert badges in your app. Just change the values of the images, colors and text.

Okay, so there may be times wherein you do not want to pass an Intent to redirect users to an app whenever the user may tap on the notification. The quickest thing that I thought might work was to pass a null Intent to the Notification object.

However, this is wrong as it can lead to problems. The correct way is to do it like this

Try it. This should do the trick.

Related Posts Plugin for WordPress, Blogger...