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

Sample Android Code for moving an image behind a selection box
Android 4.4.4 can not connect to Nordic semi SDK 13 devices
Unable to set drawable as background on a textview in api 19
Android Make one request with post method, but it save 2 data in database
Android command is depreciated after updating SDK
The resolution doesn't fit the screen
Camera2 API Real-Time OCR
Android ListView generated from SQLite database not displaying on phone screen (but displaying on emulator)
How to filter (not search) Listview BaseAdapter
The Activity restart after saving data in Firebase
How do I use ConstraintSet in Android to stack TextViews horizontally?
Turbolinks Android Adaptor - back button where to start
How to fix Android ListView Rendering Error where the checkboxes of the list items disappear?
SharedPreferences on first run are not saved when pressing Back Button
getfeatures of kml layer
How to add Firebase ChildEventlistener in Broadcast receiver

Categories

HOME
gpu
case
youtube-data-api-v3
components
nuget
r-googlesheets
rendering
database-normalization
frontend
flume
owin
siddhi
frequency-distribution
internationalization
feathersjs
video-editing
springfox
backpack-for-laravel
pagespeed
dataflow-diagram
imageresizer
mongoid6
resourcebundle
xunit
strongname
interbase
custom-post-type
fragment-backstack
ms-access-2003
linked-data
realm-mobile-platform
contacts
processwire
engine.io
news
xv6
plaintext
apriori
contract
getchar
linter
robomongo
datamaps
x-ray
yii2-user
colorbar
opengl-4
branch-prediction
stripe-connect
slackware
dimension
refinerycms
google-query-language
stream-processing
angular-ui-typeahead
spreadjs
bizagi
hadoop-partitioning
sklearn-pandas
crouton-os
spring-retry
boomerang
toran-proxy
java-money
computer-architecture
vigenere
intel-c++
binomial-theorem
atoi
airbrake
kubuntu
grouping-sets
cross-join
iiop
primitive-types
device-tree
linkedin-jsapi
lambda-architecture
mintty
lnk
ecslidingviewcontroller
spring-3
embedded-fonts
cocoalibspotify-2.0
mvc-editor-templates
scmmanager
node-blade
mysql-error-2013
dopostback
curb
adobe-media-server
subgraph
database-create
kqueue
agility.js
workflow-services
landscape-portrait
uipagecontrol
collectionviewsource
instantiationexception
globals
object-database
binomial-heap
isapi-extension
opml
pos-for-.net
lobo-cobra
fault-tolerance
information-management

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