Android wear - Notification - Image Span is not working
I am using ImageSpan in Android wear notification for styling in notification, but it's not working. Please tell me the procedure how to use ImageSpan in notifications any help is Appreciated. Following sample code i'm using.
SpannableStringBuilder title = new SpannableStringBuilder();
title.setSpan(new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE),title.length()+2,title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Thanks in advance.
android notifications android-notifications wear-os
add a comment |
I am using ImageSpan in Android wear notification for styling in notification, but it's not working. Please tell me the procedure how to use ImageSpan in notifications any help is Appreciated. Following sample code i'm using.
SpannableStringBuilder title = new SpannableStringBuilder();
title.setSpan(new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE),title.length()+2,title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Thanks in advance.
android notifications android-notifications wear-os
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58
add a comment |
I am using ImageSpan in Android wear notification for styling in notification, but it's not working. Please tell me the procedure how to use ImageSpan in notifications any help is Appreciated. Following sample code i'm using.
SpannableStringBuilder title = new SpannableStringBuilder();
title.setSpan(new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE),title.length()+2,title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Thanks in advance.
android notifications android-notifications wear-os
I am using ImageSpan in Android wear notification for styling in notification, but it's not working. Please tell me the procedure how to use ImageSpan in notifications any help is Appreciated. Following sample code i'm using.
SpannableStringBuilder title = new SpannableStringBuilder();
title.setSpan(new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE),title.length()+2,title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Thanks in advance.
android notifications android-notifications wear-os
android notifications android-notifications wear-os
asked Jan 15 '15 at 7:18
rgu
255
255
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58
add a comment |
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58
add a comment |
1 Answer
1
active
oldest
votes
You can not use ImageSpan in Notification.
If you want to show images, there are two approaches to do it.
1. Custom Notification
This is a code snip
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. Use Unicode Data
Code snip
String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
public static final String newString(int codePoint) {
return new String(Character.toChars(codePoint));
}
Then use originalStr as the Title Text.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27958429%2fandroid-wear-notification-image-span-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can not use ImageSpan in Notification.
If you want to show images, there are two approaches to do it.
1. Custom Notification
This is a code snip
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. Use Unicode Data
Code snip
String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
public static final String newString(int codePoint) {
return new String(Character.toChars(codePoint));
}
Then use originalStr as the Title Text.
add a comment |
You can not use ImageSpan in Notification.
If you want to show images, there are two approaches to do it.
1. Custom Notification
This is a code snip
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. Use Unicode Data
Code snip
String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
public static final String newString(int codePoint) {
return new String(Character.toChars(codePoint));
}
Then use originalStr as the Title Text.
add a comment |
You can not use ImageSpan in Notification.
If you want to show images, there are two approaches to do it.
1. Custom Notification
This is a code snip
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. Use Unicode Data
Code snip
String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
public static final String newString(int codePoint) {
return new String(Character.toChars(codePoint));
}
Then use originalStr as the Title Text.
You can not use ImageSpan in Notification.
If you want to show images, there are two approaches to do it.
1. Custom Notification
This is a code snip
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. Use Unicode Data
Code snip
String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
public static final String newString(int codePoint) {
return new String(Character.toChars(codePoint));
}
Then use originalStr as the Title Text.
edited Nov 13 '18 at 3:14
answered Aug 21 '15 at 11:32
RxRead
1,65211121
1,65211121
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27958429%2fandroid-wear-notification-image-span-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
yes, imagespan can not work in notification currently, and i get the official response is that the google design it is.
– Jimmy Chen
Mar 10 '15 at 2:58