1. Check out our companion app, Forums for Android! Download from Google Play

ImageView from URL

Discussion in 'Application Development' started by davidkebo, Nov 24, 2009.

  1. davidkebo

    davidkebo Member
    Thread Starter
    6

    Nov 3, 2009
    7
    2
    6
    Hello,
    Im trying to display a url image in an ImageView container on the screen.
    I see the image, but sometimes the application crashes. I am wondering if im using the stream properly.
    Code:
    URL url = new URL("http://192.168.1.111/jpg/image.jpg");
    InputStream stream = url.openStream();
    Bitmap bmp = BitmapFactory.decodeStream(stream);
    stream.close();
    myImageView.setImageBitmap(bmp);

    Any help or suggestions ?
    Thanks
     

    Advertisement

Share This Page

Loading...