[Java]
Copy Code code as follows:
public static Bitmap Getbitmapfromserver (String imagepath) {
HttpGet get = new HttpGet (ImagePath);
HttpClient client = new Defaulthttpclient ();
Bitmap pic = null;
try {
HttpResponse response = Client.execute (get);
httpentity entity = response.getentity ();
InputStream is = Entity.getcontent ();
Pic = Bitmapfactory.decodestream (IS); The key is this code
catch (Clientprotocolexception e) {
E.printstacktrace ();
catch (IOException e) {
E.printstacktrace ();
}
return pic;
}
public static Bitmap Getbitmapfromserver (String imagepath) {
HttpGet get = new HttpGet (ImagePath);
HttpClient client = new Defaulthttpclient ();
Bitmap pic = null;
try {
HttpResponse response = Client.execute (get);
httpentity entity = response.getentity ();
InputStream is = Entity.getcontent ();
Pic = Bitmapfactory.decodestream (IS); The key is this code
catch (Clientprotocolexception e) {
E.printstacktrace ();
catch (IOException e) {
E.printstacktrace ();
}
return pic;
}
Where ImagePath is your picture path,
Finally, you can display the picture on your phone:
[Java]
Copy Code code as follows:
Imageview.setimagebitmap (bitmap);