Reputation: 382
I am building an Android Things "kiosk" style application and I want an image to show in the background like a wallpaper. I'm using Unsplash Source to get a random image but the source URL (https://source.unsplash.com/1080x1920/?long-exposure) always redirects to an image URL, so I can't use this:
InputStream is = (InputStream) new URL("https://source.unsplash.com/1080x1920/?long-exposure").getContent();
Drawable d = Drawable.createFromStream(is, "");
niceWallpaper.setImageDrawable(d);
Is there a way to do this?
Upvotes: 0
Views: 193
Reputation: 536
Using Picasso
can solve your problem.
String yourUrl = "https://source.unsplash.com/1080x1920/?long-exposure";
Picasso.with(MyApplication.getAppContext()).load(yourUrl).placeholder(defaultImage).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(YourImageView);
Upvotes: 2