I am making an app and I would like to keep the images updated when I change them. I am not sure how to display an image from a specific URL.
any help and suggestions is appreciated
thank you
I am making an app and I would like to keep the images updated when I change them. I am not sure how to display an image from a specific URL.
any help and suggestions is appreciated
thank you
Possibly a duplicate, as mentioned before, but still, I'd use an AsyncTask to load an image from an URL (which doesn't seems to be the case in the provided links).
Something along these lines:
new AsyncTask<String, Void, Drawable>() {
@Override
protected Drawable doInBackground(String... params) {
Drawable result = null;
try {
URL url = new URL(params[0]);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
InputStream input = connection.getInputStream();
result = Drawable.createFromStream(input, "src");
} catch (MalformedURLException muExp) {
Log.e(TAG, "Bad URL provided!", muExp);
} catch (IOException ioExp) {
Log.e(TAG, "Error loading content from URL!", ioExp);
}
return result;
}
@Override
protected void onPostExecute(Drawable result) {
// Do something with your Drawable, in UI, here...
}
}.execute("http://myimageurl.com/image.jpg");