[Java]
Copy codeThe Code is as follows: public static Bitmap getBitmapFromServer (String imagePath ){
HttpGet = new HttpGet (imagePath );
HttpClient client = new DefaultHttpClient ();
Bitmap pic = null;
Try {
HttpResponse response = client.exe cute (get );
HttpEntity entity = response. getEntity ();
InputStream is = entity. getContent ();
Pic = BitmapFactory. decodeStream (is); // The key is the code.
} Catch (ClientProtocolException e ){
E. printStackTrace ();
} Catch (IOException e ){
E. printStackTrace ();
}
Return pic;
}
Public static Bitmap getBitmapFromServer (String imagePath ){
HttpGet = new HttpGet (imagePath );
HttpClient client = new DefaultHttpClient ();
Bitmap pic = null;
Try {
HttpResponse response = client.exe cute (get );
HttpEntity entity = response. getEntity ();
InputStream is = entity. getContent ();
Pic = BitmapFactory. decodeStream (is); // The key is the code.
} Catch (ClientProtocolException e ){
E. printStackTrace ();
} Catch (IOException e ){
E. printStackTrace ();
}
Return pic;
}
Where imagePath is your image path,
Finally, you can display the image on your mobile phone:
[Java]
Copy codeThe Code is as follows: imageView. setImageBitmap (bitmap );