How to set image to imageview from https url android? -


i want set image in imageview,my image coming https url.here using picaso loadiing image,but not able image https url.if change https http able image,but want image https url .please solve problem

 @override  protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_picaso_image);     imageview img=(imageview)findviewbyid(r.id.imageview1);      string url="https://www.bahrainlocator.gov.bh/blm_data/point_1418646022.jpg";       picasso.with(this).load(url).into(img);  } 

edit: please try use activity.this context,if using fragments use getactivity()

download picasso library http://square.github.io/picasso/

then try using method

picasso.with(context)     .load(url)     .placeholder(r.drawable.user_placeholder)     .error(r.drawable.user_placeholder_error)     .into(imageview); 

and have issues high resolution images , https protocols if still cant load picasso try glide library

 string url = myurls.get(position);      glide.with(myfragment)         .load(url)         .centercrop()         .placeholder(r.drawable.loading_spinner)         .crossfade()         .into(myimageview); 

you can download glide here https://github.com/bumptech/glide/releases

update: reason https appended links not loaded in both glide , picasso in case used universal image loading library..

 imageloader imageloader;     imageview iv;     private imageloadinglistener animatefirstlistener = null;     displayimageoptions doption_two = null; 

inside oncreate

imageloader = imageloader.getinstance();         doption_two = new displayimageoptions.builder()                 .showimageonloading(r.drawable.ic_launcher)                 .showimageforemptyuri(r.drawable.icon)                 .showimageonfail(r.drawable.icon).cacheinmemory(true)                 .cacheondisc(true).considerexifparams(true).build();         animatefirstlistener = new animatefirstdisplaylistener();         iv = (imageview) findviewbyid(r.id.imageview1);          string url = "http://www.bahrainlocator.gov.bh/blm_data/point_1418646022.jpg";          imageloader.displayimage(url, iv, doption_two, animatefirstlistener); 

also declare static inner class

private static class animatefirstdisplaylistener extends             simpleimageloadinglistener {          static final list<string> displayedimages = collections                 .synchronizedlist(new linkedlist<string>());          @override         public void onloadingcomplete(string imageuri, view view,                 bitmap loadedimage) {             if (loadedimage != null) {                 imageview imageview = (imageview) view;                 boolean firstdisplay = !displayedimages.contains(imageuri);                 if (firstdisplay) {                     fadeinbitmapdisplayer.animate(imageview, 500);                     displayedimages.add(imageuri);                 }             }         }     } 

as helper classes, have added

uilapplication.java

public class uilapplication extends application {     @targetapi(build.version_codes.gingerbread)     @suppresswarnings("unused")     @override     public void oncreate() {         if (config.developer_mode                 && build.version.sdk_int >= build.version_codes.gingerbread) {             strictmode.setthreadpolicy(new strictmode.threadpolicy.builder()                     .detectall().penaltydialog().build());             strictmode.setvmpolicy(new strictmode.vmpolicy.builder()                     .detectall().penaltydeath().build());         }          super.oncreate();          initimageloader(getapplicationcontext());     }      public static void initimageloader(context context) {         // configuration tuning custom. can tune every option,         // may tune of them,         // or can create default configuration         // imageloaderconfiguration.createdefault(this);         // method.         imageloaderconfiguration config = new imageloaderconfiguration.builder(                 context).threadpriority(thread.norm_priority - 2)                 .denycacheimagemultiplesizesinmemory()                 .disccachefilenamegenerator(new md5filenamegenerator())                 .tasksprocessingorder(queueprocessingtype.lifo)                 .writedebuglogs() // remove release app                 .build();         // initialize imageloader configuration.         imageloader.getinstance().init(config);     } } 

and constants.java

/**  * @author george thomas  */ public final class constants {        public static class config {         public static final boolean developer_mode = false;     }   } 

make sure make application name in manifest .uilapplication

<application         android:name=".uilapplication"         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" > 

you can find jar file @ univerasl image loader


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -