image display from servlet
I need to display image from servlet to my android applic开发者_运维问答ation how can i do it please some one help me thanks in advance
I would suggest following steps:
- Use AsyncTask to download image from the servlet asynchronously, save it to file (either in memory or on memory card)
- In activity, place ImageView where you want image to be shown.
- Convert loaded image to bitmap:
FileInputStream fis;
Bitmap image;
try {
fis = new FileInputStream("path to downloaded image");
Bitmap image = BitmapFactory.decodeStream(fis);
} catch (FileNotFoundException e) {
// handle exception
}
4. Set bitmap to ImageView.
精彩评论