Loading Bitmap to ImageView from URL in android -


i using following method retrieve bitmap url , pass on imageview , imageview not being updated.

 public static bitmap loadimagefromweboperations(string url) {     bitmap bitmap;     try {         inputstream = new url(url).openstream();        bitmap = bitmapfactory.decodestream(is);         return bitmap;     } catch (exception e) {          return null;     } 

call -

  mov1_poster.setimagebitmap(vpmovies.loadimagefromweboperations(mov_details[0][7])); //doesn't work    toast.maketext(this,"url \n"+mov_details[0][7],toast.length_long).show();    // shows url of image (just check url not null) 

is there doing wrong ? please help.

public class downloadimagetask extends asynctask<string, void, bitmap> {     private imageview imageview;     private bitmap image;      public downloadimagetask(imageview imageview) {         this.imageview = imageview;     }      protected bitmap doinbackground(string... urls) {         string urldisplay = urls[0];         try {             inputstream in = new java.net.url(urldisplay).openstream();             image = bitmapfactory.decodestream(in);         } catch (exception e) {             image = null;         }         return image;     }      @suppresslint("newapi")     protected void onpostexecute(bitmap result) {         if (result != null) {             imageview.setimagebitmap(result);         }     } } 

now call in code:

 new downloadimagetask(your_image_view).execute("your_url"); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -