Created
February 21, 2018 16:02
-
-
Save crossphd/a4b03e3667f690ef1f35c6caff1de866 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { | |
ImageView bmImage; | |
public DownloadImageTask(ImageView bmImage) { | |
this.bmImage = bmImage; | |
} | |
protected Bitmap doInBackground(String... urls) { | |
String urldisplay = urls[0]; | |
Bitmap bmp = null; | |
try { | |
InputStream in = new java.net.URL(urldisplay).openStream(); | |
bmp = BitmapFactory.decodeStream(in); | |
} catch (Exception e) { | |
Log.e("Error", e.getMessage()); | |
e.printStackTrace(); | |
} | |
return bmp; | |
} | |
protected void onPostExecute(Bitmap result) { | |
bmImage.setImageBitmap(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment