Bad practice of use of AsyncTask,
You are trying to update your Main UI Thread from doInBackGround()
as AsyncTask never allowed that.
Never update your UI from doInBackGround()
of AsyncTask as its only worker thread. So write your Main UI updatation code in onPostExecute()
method of AsyncTask..
@Override
protected Void doInBackground(Void... params) {
try {
URL myFileUrl = new URL("http://sposter.smartag.my/images/chicken_soup.jpg");
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
downloadBitmap = BitmapFactory.decodeStream(is);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
onPostExecute()
{
ImageView image = (ImageView) findViewById(R.id.imview);
image.setImageBitmap(downloadBitmap);
}