Java – Android notifications display images from strings without unicode

Android notifications display images from strings without unicode… here is a solution to the problem.

Android notifications display images from strings without unicode

I want to show a different image or smiley face in the notification from the string
For example

“Hi, I’m your friend Sam”

I’ve tried using image setters
There is also a string generator, but it displays obj obj instead of an image
Below the complete code

String mystring = "Hi i am your friend <img /src='friend.png'/> Sam";
final NotificationManager mgr = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.eat2, "notification", System.currentTimeMillis());
 This pending intent will open after notification click
PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0);
note.setLatestEventInfo(this,mystring, mystring, i);
 After uncomment this line you will see number of notification arrived note.number = 2;
mgr.notify(12, note);

Related Problems and Solutions