Android 5.0
通知未显示我定义的表情符号图像,它会用系统表情符号图像替换我的表情符号图像。如何解决?
Notification notification = new Notification();
notification.icon = R.drawable.nav_logo;
notification.tickerText = charSequence;//ticker;
notification.when = System.currentTimeMillis();
int defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
notification.defaults = defaults;
notification.contentView = getMessageRemoteView(context, emjin);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
notification.bigContentView = getMessageRemoteView(context, emjin);
}
private static RemoteViews getMessageRemoteView (Context context, String emojin) {
RemoteViews view = new RemoteViews(context.getPackageName(), R.layout.notification_msg_item);
view.setTextViewText(R.id.notification_msg_content,EmojiconUtils.emojify(context, emojin);
return view;
}
答案 0 :(得分:0)
EmojiconUtils是一个tmp类
public class EmojiconUtils {
public static final String TAG = "EmojiconUtils";
public static SpannableString emojify(Context context, CharSequence input) {
if(TextUtils.isEmpty(input)) {
return new SpannableString("");
}
SpannableString spanStr = new SpannableString(input);
while (i < input.length()) {
spanStr.setSpan(new ImageSpan(context, getBitmap(context, R.drawable.emoji_1f38d)), i, i + 1, 33);
}
return spanStr;
}
public static Bitmap getBitmap(Context context, resourceId) {
return BitmapFactory.decodeResource(context.getResources(), resourceId);
}
}