class
GetImageTask
extends
AsyncTask<String, Void, Bitmap>{
InputStream is =
null
;
@Override
protected
Bitmap doInBackground(String... params) {
//TODO Auto-generated method stub
URL myFileUrl =
null
;
Bitmap bitmap =
null
;
InputStream is =
null
;
HttpURLConnection conn =
null
;
try
{
myFileUrl =
new
URL(params[0]);
}
catch
(MalformedURLException e) {
e.printStackTrace();
}
try
{
conn = (HttpURLConnection)myFileUrl
.openConnection();
conn.setDoInput(
true
);
conn.connect();
is =conn.getInputStream();
bitmap =BitmapFactory.decodeStream(is);
is.close();
}
catch
(IOException e) {
e.printStackTrace();
}
finally
{
try
{
if
(is !=
null
){
is.close();
}
if
( conn !=
null
){
conn.disconnect();
}
}
catch
(IOException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
}
return
bitmap;
}
@Override