android - "resolveUri failed on bad bitmap uri" when putting image on ListView -


hey, i'm new android , have slight problem. i'm trying put listview images loaded through url. works far, images wont show up. logcat says this:

02-23 19:20:48.447: info/system.out(833): resolveuri failed on bad bitmap uri: android.graphics.drawable.bitmapdrawable@405359b0 

its not finding image, have no idea why. using r.drawable.icon works though. can me out? heres source:

public class main extends activity {         private listview lv_main;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          lv_main = (listview) findviewbyid(r.id.listviewmain);          arraylist<hashmap<string, string>> listitem = new arraylist<hashmap<string, string>>();          hashmap<string,string> map;          map = new hashmap<string, string>();         map.put("title", "a title goes here");         map.put("details", "details blaa");         map.put("cover", string.valueof(main.this.loadimagefromweboperations("http://www.google.com/intl/en_all/images/srpr/logo1w.png"));         //this works fine: map.put("cover", string.valueof(r.drawable.icon));         listitem.add(map);          map = new hashmap<string, string>();         map.put("title", "2nd title");         map.put("details", "more details");         map.put("cover", string.valueof(main.this.loadimagefromweboperations("http://www.google.com/images/srpr/nav_logo37.png"));         //this works fine: map.put("cover", string.valueof(r.drawable.icon));         listitem.add(map);          simpleadapter mschedule = new simpleadapter (this.getbasecontext(), listitem, r.layout.listviewitem, new string[] {"cover", "title", "details"}, new int[] {r.id.cover, r.id.title, r.id.details});          lv_main.setadapter(mschedule);      }      public drawable loadimagefromweboperations(string url) {         try         {                 inputstream = (inputstream) new url(url).getcontent();                 drawable d = drawable.createfromstream(is, "src name");                 return d;         }catch (exception e) {                 system.out.println("exc="+e);                 return null;         }     } } 

thanks in advance. rob

i have resolved issue. using code solve issue.

here 'path' local file system path can got using: environment.getexternalstoragedirectory().getabsolutepath()

public static string loadimagefromweboperations(string url, string path) {     try {         inputstream = (inputstream) new url(url).getcontent();          system.out.println(path);         file f = new file(path);          f.createnewfile();         fileoutputstream fos = new fileoutputstream(f);         try {              byte[] b = new byte[100];             int l = 0;             while ((l = is.read(b)) != -1)                 fos.write(b, 0, l);          } catch (exception e) {          }          return f.getabsolutepath();     } catch (exception e) {         system.out.println("exc=" + e);         return null;      } } 

hope helps :).


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -