Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class LoadImageTask extends AsyncTask<String, Void, Bitmap> {
- @Override
- protected Bitmap doInBackground(String... image_url) {
- URL[] myURL = new URL[1];
- try {
- myURL[0] = new URL(image_url[0]);
- return BitmapFactory.decodeStream((InputStream) myURL[0].getContent());
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
- @Override
- protected void onPostExecute(Bitmap bitmap) {
- if (bitmap != null) {
- //ImageView set image bitmap
- iv_url.setImageBitmap(bitmap);
- } else {
- Toast.makeText(getApplicationContext(), "Error Loading Image !", Toast.LENGTH_SHORT).show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement