Android wear - Notification - Image Span is not working












2














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.










share|improve this question






















  • 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
















2














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.










share|improve this question






















  • 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














2












2








2







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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












1 Answer
1






active

oldest

votes


















4














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;


enter image description here



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.
enter image description here






share|improve this answer























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


    }
    });














    draft saved

    draft discarded


















    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









    4














    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;


    enter image description here



    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.
    enter image description here






    share|improve this answer




























      4














      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;


      enter image description here



      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.
      enter image description here






      share|improve this answer


























        4












        4








        4






        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;


        enter image description here



        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.
        enter image description here






        share|improve this answer














        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;


        enter image description here



        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.
        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 3:14

























        answered Aug 21 '15 at 11:32









        RxRead

        1,65211121




        1,65211121






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python