I am trying to download and show a image in my imageview from URL that i will get dyncamically .I have tried this way
URL url = new URL(parsedWeatherRespo
As you are running Network Related work on MainThread i.e. UIThread which cause UIThread not to laid out it's Viewon Screen or Activity. That's according to ThreadPolicy all the time consuming and variable operation are need to performed on AysncTask or Thread.
As per below LongOperation is AsyncTask which can be executed by calling execute() on it.
new LongOperation().execute();
private class LongOperation extends AsyncTask {
@Override
protected String doInBackground(Bitmap... params)
{
try
{
URL url = new URL(parsedWeatherResponse.getWeatherIconUrl());
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bmp;
}
@Override
protected void onPostExecute(Bitmap bmp)
{
super.onPostExecute(result);
weather_image.setImageBitmap(bmp);
}
@Override
protected void onPreExecute() {
}
@Override
protected void onProgressUpdate(Void... values) {
}
}