google api - Android Studio: ImageManager get image from web -


when use code covers imageloadedlistener red , says not recognize such method. first time using imagemager if tell me wrong , may give me sample code, can check usage of imagemanager. there way safe image on device , string or int(for r.id.drawable) image in future references?

 imageview iv;         setcontentview(r.layout.activity_main); iv = (imageview)findviewbyid(r.id.imageview);         imagemanager imagemanager;          uri uri;         try {              uri = new uri("http://suburban-k9.com/wp-content/uploads/2011/03/small-dog-sydrome-300x300.jpg");           } catch (urisyntaxexception e) {             e.printstacktrace();             uri=null;         }         context context = getapplication().getapplicationcontext();         imagemanager = imagemanager.create(context);          log.v("app", "loadimagefromgoogle manager created image #" + id);          imagemanager.loadimage(new onimageloadedlistener() {             @override             public void onimageloaded(uri uri, drawable drawable, boolean b) {                      log.v("app", "loadimagefromgoogle image loaded #" + id);                      mybitmap = ((bitmapdrawable) drawable).getbitmap();                     bytearrayoutputstream stream = new bytearrayoutputstream();                     mybitmap.compress(bitmap.compressformat.png, 100, stream);                     byte[] bytearray = stream.tobytearray();                       log.v("app", "loadimagefromgoogle image added #" + id);                 }           },uri,android.r.drawable.btn_default);   iv.setimagebitmap(mybitmap);       }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     } 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -