简体   繁体   English

android 5.0通知没有显示我的定义表情符号图像

[英]android 5.0 notification not showing my define emoji image

Android 5.0 notification does not show my defined emoji image, it replaces my emoji image by system emoji image. Android 5.0通知不显示我定义的表情符号图像,它用系统表情符号图像替换我的表情符号图像。 How to resolve? 怎么解决?

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;
}

The EmojiconUtils is a tmp class 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);
    }

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM