Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android磨损-通知-图像范围不工作_Android_Notifications_Android Notifications_Wear Os - Fatal编程技术网

Android磨损-通知-图像范围不工作

Android磨损-通知-图像范围不工作,android,notifications,android-notifications,wear-os,Android,Notifications,Android Notifications,Wear Os,我正在Android wear notification中使用ImageSpan进行通知中的样式设置,但它不起作用。请告诉我如何在通知中使用ImageSpan的过程,非常感谢您的帮助。下面是我正在使用的示例代码 SpannableStringBuilder title=新的SpannableStringBuilder() title.setSpan(新图像SPAN(上下文、bmp、图像SPAN.ALIGN_基线)、title.length()+2、title.length()、Spannable

我正在Android wear notification中使用ImageSpan进行通知中的样式设置,但它不起作用。请告诉我如何在通知中使用ImageSpan的过程,非常感谢您的帮助。下面是我正在使用的示例代码

SpannableStringBuilder title=新的SpannableStringBuilder()

title.setSpan(新图像SPAN(上下文、bmp、图像SPAN.ALIGN_基线)、title.length()+2、title.length()、Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)


提前感谢。

您不能在通知中使用ImageSpan


如果要显示图像,有两种方法。
1。自定义通知 这是一个密码剪

      RemoteViews contentViews = new RemoteViews(context.getPackageName(), R.layout.view_notice_common);
        SimpleDateFormat fmt = new SimpleDateFormat("HH:mm");
        contentViews.setTextViewText(R.id.notice_time, fmt.format(Calendar.getInstance().getTime()));
        contentViews.setTextViewText(R.id.notice_title, title);
        contentViews.setTextViewText(R.id.notice_extend_message, content);
        Bitmap smallBitmap = bundle.getParcelable("APP_ICON");
        if (smallBitmap != null) {
            contentViews.setImageViewBitmap(R.id.notice_drawable, smallBitmap);
        } else {
            contentViews.setImageViewResource(R.id.notice_drawable, R.drawable.icon);
        }
        notification.contentView = contentViews;

2。使用Unicode数据
代码剪报

  String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
  public static final String newString(int codePoint) {
     return new String(Character.toChars(codePoint));
}
然后使用originalStr作为标题文本。

是的,imagespan目前无法在notification中工作,我得到的官方回应是,它是google设计的。