android view web pictures in gallery

Posted by bitma on Stack Overflow See other posts from Stack Overflow or by bitma
Published on 2010-06-13T15:19:10Z Indexed on 2010/06/13 15:22 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

I am new to android, I just finished Hello gallery tutorial, and a web pciture tutorial. Now I want to know how can I show some web images in gallery?

the hello gallery code is from andorid tutor

this is Web gallery code, I want to load some pictures from web and then show them in gallery, how can I write it?

public class WebGallery extends Activity {  
String imageUrl = "http://i.pbase.com/o6/92/229792/1/80199697.uAs58yHk.50pxCross_of_the_Knights_Templar_svg.png"; 

Bitmap bmImg;  
ImageView imView;  


public void onCreate(Bundle savedInstanceState) {  
super.onCreate(savedInstanceState);  
setContentView(R.layout.main);  
imView = (ImageView) findViewById(R.id.imview);  
imView.setImageBitmap(getRemoteImage(imageUrl));  
}  

public Bitmap getRemoteImage(String imageUrl) { 
    try { 
    URL aURL = new URL(imageUrl);
     final URLConnection conn = aURL.openConnection(); 
     conn.connect(); 
     final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream()); 
     final Bitmap bm = BitmapFactory.decodeStream(bis); 
     bis.close(); 
     return bm; 
} catch (IOException e) { 
     Log.d("DEBUGTAG", "Oh noooz an error..."); 
} 
return null; 
}
}  

© Stack Overflow or respective owner

Related posts about android

Related posts about image