android - Image not loading in the imageview from the url -


i trying set bitmap imageview using url in following way : -

     inputstream in = new java.net.url(url).openstream();       image = bitmapfactory.decodestream(in);        in.close(); 

when image tomcat server using url : -

http://192.168.1.6:8080/webapp/images/image.jpg 

this works totally .

the problem , when set url of image other website - http://i.ytimg.com/vi/ipk1-aqawyw/maxresdefault.jpg

then no image being set on imageview.

i tried using ip address instead of domain name , still no luck.

do need set port number ? in case of loading image server ?

if yes , port number should use ?

i try 2 things:

  • check if device on same net server because seems local ip
  • have tried execute code on main thread. in android, changes have executed in main thread, if getting web image (executing asynk taksk). can try this:

    runonuithread(new runnable() {

             @override          public void run() {               image = bitmapfactory.decodestream(in);                      }           }); 

good luck this!!


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -