android


I want to show unread notification count on my app icon like whatsapp


I have created notification in my app using volley library it's calling to firebase server my problem is when i push the notification in specific user(device) the update notification only showing and unread notification count number is not showing, so i want to unread notification count number how to display in my app icon. help me ..
My code is:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG="MyMessageservice";
RemoteMessage remoteMessage;
#Override
public void onMessageReceived(RemoteMessage remoteMessage){
String title=remoteMessage.getNotification().getTitle();
String message=remoteMessage.getNotification().getBody();
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// String click_action=remoteMessage.getNotification().getClickAction();
Intent intent=new Intent(this,VisitorList.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri notificattionSound= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(this);
notificationbuilder.setContentTitle(title);
notificationbuilder.setContentText(message);
notificationbuilder.setAutoCancel(true);
notificationbuilder.setSound(notificattionSound);
notificationbuilder.setSmallIcon(R.drawable.ic_launcher);
notificationbuilder.setContentIntent(pendingIntent);
notificationbuilder.setAutoCancel(true);
notificationManager.notify(0, notificationbuilder.build());
}
}
If you need to show notification count on app icon in your home screen, the function it self is not included in android SDK by default but every manufacture may or may not give you access to it's custom api that allow that manufacture to do such functionality for example the following code work on samsung touchwiz
Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
intent.putExtra("badge_count", count);
intent.putExtra("badge_count_package_name", "your package name");
sendBroadcast(intent);
the following work on sony launcher
Intent intent = new Intent("com.sonyericsson.home.action.UPDATE_BADGE");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", count);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", "your package name");
sendBroadcast(intent);
as you can see it's different code for every launcher which is kinda lame and would give you headache
fortunately someone gather most of famous launchers in one library ShortcutBadger
which as you can find on their github the launchers they support

Related Links

Playing each note separately using android-mid-lib
Duplicating sonar project names in the Name list in Sonarqube dashboard
java.util.ArrayList cannot be cast to android.os.Parcelable. key expected Parcelable but value was a java.util.ArrayList
Clear Focus of searchview in popupwindow and show keybaord when searchview clicked
How to change camera direction in osmdroid?
Swipelayout doesn't close
Android: Debug app-release.apk
Android - Why Doesn't Android Obey The Pythagorean Theorem?
running adb with python: executing a program and ending it
Developing two android app that can send/trigger notification to each other
Android: while i select an item from navigation drawer, it is not moving to the new screen
Why there is no ArrayAdapter that takes 2 lists as an arguments [duplicate]
How to copy file using adb to android directory accessible from PC
ListView maxWidth is not working - Always 100% width
How to open Facebook profile in Android app with numerical user-id
How to create a NavigationView programmatically [duplicate]

Categories

HOME
cygwin
fuelux
cheerio
ggplot2
telegram
youtube-data-api-v3
swt
obfuscation
rendering
edge
xbee
cublas
frontend
boto3
pkcs#11
octave
activecollab
emoji
naivebayes
eip
3nf
flatpak
parameter-passing
gruntfile
keytool
digital-signature
replication
googlebot
ksh
aggregation
froala
windows-server-2003
stackexchange
bulletphysics
ms-access-web-app
angular-translate
errbot
testbed
hard-drive
reverse
projects-and-solutions
mongoose-schema
trigonometry
drupal-theming
clang++
flask-login
stylecop
fwrite
azure-cli
dt
flac
change-tracking
slackware
pacemaker
envi
mongodb-php
jodd
i386
mediametadataretriever
lua-telegram-bot
angular-ui-typeahead
thread-sleep
false-sharing
vhosts
decimalformat
fiware-monitoring
extjs-grid
nutiteq
mruby
webfinger
cocos3d
tweenlite
websphere-esb
git-repo
windows-embedded-standard
ie8-compatibility-mode
ebay-lms
modular
poker
composite-component
server-administration
fusefabric
mapping-by-code
node-redis
jquery-tools
xcelsius
nhprof
load-time
office-2007
zend-rest
opml
murmurhash
fault-tolerance
application-planning

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App