0

I am trying to set background image in the timeline of google glassware.

How do I do it? How do I get image in view page?

I try to set image url as attachment like

TimelineItem timelineItem = new TimelineItem(); 
timelineItem.setText("Hello world"); 
InputStreamContent mediaContent = new InputStreamContent(contentType, attachment); 
service.timeline().insert(timelineItem, mediaContent).execute();

then service.timeline().insert(timelineItem, mediaContent).execute(); gives null pointer exception.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Moddasir
  • 1,449
  • 13
  • 33

1 Answers1

1

Have you had a look at the Google Mirror API Playground?

One of the templates shows a timeline card with a full-bleed background image, using this html for the card:

<article class="photo">
  <img src="%background-image-url%" width="100%" height="100%">
  <div class="photo-overlay"></div>
  <section>
    <p class="text-auto-size">%CardText&</p>
  </section>
</article>

Alternatively you can also add the image you want as attachment and only provide the text part in the timeline item. This will use the attached image as full-bleed background image and display the text on top, as described here: https://developers.google.com/glass/timeline#inserting_a_timeline_item_with_media

Scarygami
  • 15,009
  • 2
  • 35
  • 24
  • I try to set image url as attachment like `TimelineItem timelineItem = new TimelineItem(); timelineItem.setText("Hello world"); InputStreamContent mediaContent = new InputStreamContent(contentType, attachment); service.timeline().insert(timelineItem, mediaContent).execute();` then `service.timeline().insert(timelineItem, mediaContent).execute();` gives null pointer exception. – Moddasir Nov 12 '13 at 14:18
  • Could you edit your original question and include the code you tried. Will be easier to read than in the comments, thanks. – Scarygami Nov 12 '13 at 15:37