我想在字符串的通知中显示不同的图像或笑脸 例如
"你好我是你的朋友Sam"
我尝试过使用图像设定器 以及字符串构建器,但它显示obj obj而不是图像 低于完整代码
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);
答案 0 :(得分:4)
我不认为在通知中将图像显示为HTML内容是不可能的。您可以在通知中显示图像和文本,如下所示。
您的Notification
如果您想在通知中显示任何图片/图标,请如下所示
Notification mNotification = new Notification.Builder(this)
.setContentTitle("New Message Received")
.setContentText("Hi I am your friend Sam")
// Here you can specify an image but it will display as icon on the left side of Notification.
.setSmallIcon(R.drawable.friend)
.setContentIntent(pIntent)
.setSound(soundUri)
.build();