I have a problem when i try to set an image URL on a Card
.
Here is the error log : unsupported image scheme: http
01-16 14:11:50.188: E/AndroidRuntime(2851): FATAL EXCEPTION: main
01-16 14:11:50.188: E/AndroidRuntime(2851):
java.lang.IllegalArgumentException: unsupported image scheme: http
01-16 14:11:50.188: E/AndroidRuntime(2851): at
com.google.android.glass.app.Card.addImage(Card.java:178)
01-16 14:11:50.188: E/AndroidRuntime(2851): at
com.example.cupofnewsglass.MainActivity.processFinish(MainActivity.java:112)
Here is my code :
// Get img of article, it return an string like : http://img.
String imgUrl = articles.get(i).getImage();
// Get Publication Date
String pubDate = createDateForGlass(articles.get(i).getPubDate());
// Convert imgUrl to an Uri
Uri imgUri = Uri.parse(imgUrl);
// Set main text in card
card.setText(title + " ago");
// Set Footer text in card
card.setFootnote(pubDate);
// Image will be in Fullscreen mode
card.setImageLayout(Card.ImageLayout.FULL);
// Set background image in card
card.addImage(imgUri);
This is working as intended, the only supported schemes for the Card builder class are file
and android.resource
.
This feature request is tracking support for web images in the Card builder class.
来源:https://stackoverflow.com/questions/21167282/googleglass-add-image-in-background-unsupported-image-scheme-http