1

how to make a http request to get image link: http://vec03.maps.yandex.ru/tiles?l=map&v=2.20.0&x=19783&y=10320&z=15 to be able to add to ImageView

Please help, I'm not good in web development.

Andrew Nodermann
  • 610
  • 8
  • 13
  • Open URL connection and get image as Bitmap now set Bitmap as ImageView. Look at this tutorial, http://android-developers.blogspot.in/2010/07/multithreading-for-performance.html – user370305 Aug 14 '12 at 10:17
  • Also http://stackoverflow.com/questions/2471935/how-to-load-an-imageview-by-url-in-android and http://stackoverflow.com/questions/6238524/how-to-show-an-image-from-an-url-in-android – user370305 Aug 14 '12 at 10:19
  • Thank you very much, it works! http://android-developers.blogspot.in/2010/07/multithreading-for-performance.html – Andrew Nodermann Aug 15 '12 at 07:28

2 Answers2

9
String imageUrl= "http://vec03.maps.yandex.ru/tiles?l=map&v=2.20.0&x=19783&y=10320&z=15";
URL url = new URL(imageUrl);
HttpURLConnection connection  = (HttpURLConnection) url.openConnection();

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);  

imageView.setImageBitmap(img );

Google it before you ask your problem in SO, avoid duplicate Questions

VenomVendor
  • 15,064
  • 13
  • 65
  • 96
0
public void setImage()
    {
     ImageView icon=(ImageView)v.findViewById(R.id.icon);


                                   Drawable image = ImageOperations(getapplicationContext(), "yuour url",
                                     "image.jpg");


                                   icon.setImageDrawable(image);
    }
private Drawable ImageOperations(Context ctx, String url,
               String saveFilename) {
              try {
               InputStream is = (InputStream) this.fetch(url);
               Drawable d = Drawable.createFromStream(is, "src");
               return d;
              } catch (MalformedURLException e) {
               e.printStackTrace();
               return null;
              } catch (IOException e) {
               e.printStackTrace();
               return null;
              }
    }
              public Object fetch(String address) throws MalformedURLException,
               IOException {
              URL url = new URL(address);
              Object content = url.getContent();
              return content;
             }
Atul Bhardwaj
  • 6,647
  • 5
  • 45
  • 63