1

according to this question we have to provide a different type of icon for notifications in android 5 or later which is fine but how i'm gonna set this new icon on my notification linked question's answer says do something like this

Notification notification = new Notification.Builder(context)
        .setAutoCancel(true)
        .setContentTitle("My notification")
        .setContentText("Look, white in Lollipop, else color!")
        .setSmallIcon(getNotificationIcon())
        .build();

return notification;



private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}

but in my case i'm creating my Notification in serverSide Code , so i have no idea what to do or how to do ? , do i have to assign this new icon in server side code or i can do this in my project's inner class ??

if anybody have any clue then guide me

P.S. - if my question is not clear enough then let me know i'll add some more detail

Community
  • 1
  • 1
remy boys
  • 2,928
  • 5
  • 36
  • 65
  • whats wrong with your code ? it's seem working – tamtom Aug 15 '16 at 05:51
  • thats not my code , this is what linked question's answer is suggesting me to do , but i'm configuring my notification in server-side code thats why i can't use it right there... @tamtom – remy boys Aug 15 '16 at 05:54

1 Answers1

1

You can keep the desired icon in your

res/drawable 

folder and then in the notification data you can tell which icon to use. e.g

data={
    "to" : "/topics/my_little_topic",
    "notification" : {
    "body" : messageBody,
    "title" : messageTitle,
    "icon" : "ic_cloud_white_48dp"
    }
}

Notice that the name of the icon in your res folder should exactly match the value of the icon property in your JSON data.

Check the following link for more info: http://code.tutsplus.com/tutorials/how-to-get-started-with-push-notifications-on-android--cms-25870

AmanSinghal
  • 2,404
  • 21
  • 22