Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create notification icon badge on Android apps (like iPhone)

I am very new to programming and would like to know what is the best way to go about creating a notification icon badge similar to the ones on the iPhone apps. This would be basically for creating a badge for the notifications that end up in the notification bar.

like image 348
Michael_19 Avatar asked Apr 06 '10 18:04

Michael_19


People also ask

How do I get notification badge on app icon Android?

If you want to change badge with number, you can be changed in NOTIFICATION SETTING on the notification panel or Settings > Notifications > App icon badges > Select Show with number.

Does Android have app badges?

Starting with 8.0 (API level 26), notification badges (also known as notification dots) appear on a launcher icon when the associated app has an active notification. Users can long-press on the app icon to reveal the notifications (alongside any app shortcuts), as shown in figure 1.


3 Answers

This is actually an answer from Mark Murphy:

For most phones, you use the number field of the Notification object. See here: http://github.com/commonsguy/cw-android/tree/master/Notifications/Notify1/

Now, there are a few phones by one major device manufacturer that have a bug, whereby the number field is ignored. I am working on getting them to fix it. So you can't absolutely rely on that red bubble being there, though it will be on most phones.

like image 194
Macarse Avatar answered Oct 05 '22 15:10

Macarse


Are you talking about a graphical icon? I created a transparent PNG using the gimp and pass that drawable id as the 1st argument to the Notification constructor.

Notification notification = new Notification(R.drawable.someicon,title,System.currentTimeMillis())
like image 38
Billy Bob Bain Avatar answered Oct 05 '22 13:10

Billy Bob Bain


I know this is very old question. May be this link is helpful is you are still looking for answer. https://github.com/leolin310148/ShortcutBadger

like image 35
Ads Avatar answered Oct 05 '22 14:10

Ads