AsyncTask ImageView from image web using setImageBitmap
<p>I have a problem to display this image in my internet.
I have no idea how to make it work.
I am new to android.</p>

<p>The problem is that part ...</p>

<pre><code>imView = (ImageView) findViewById(R.id.imageView1); 
imView.setImageBitmap(bm); //error
</code></pre>

<p>Thank you.</p>

<p>my code</p>

<pre><code>public class CarregaImagem extends AsyncTask&lt;String, Void, String&gt;{
    String imageUrl = "http://www.cuboweb.com.br/android/images/logoconsulfarma.png";
    private ProgressDialog progress;
    private Activity activity;
    Bitmap bmImg;

    public CarregaImagem(Activity activity){
        this.activity = activity;
    }

    protected void onPreExecute() {
        progress = new ProgressDialog(activity);
        progress.setTitle("Aguarde...");
        progress.setMessage("Carregando..."); 
        progress.show();    
    }

    protected String doInBackground(String... params) { 
        // TODO Auto-generated method stub
        try { 
            URL aURL = new URL(imageUrl);
            final URLConnection conn = aURL.openConnection(); 
            conn.connect();
            final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
            final Bitmap bm = BitmapFactory.decodeStream(bis);
            BitmapFactory.decodeStream(new URL(imageUrl).openConnection().getInputStream()); 
            bis.close();
        } catch (IOException e) { 
            imageUrl = "";
        } catch(Exception f){
            imageUrl = "";
        }
        return imageUrl;        
    }

    protected void onPostExecute(String imageUrl) {

        if(!imageUrl.equals("")){
            imView = (ImageView) findViewById(R.id.imageView1); 
            imView.setImageBitmap(bm); //error 
        } else{
            Toast.makeText(activity, "Não foi possível obter resultados", Toast.LENGTH_LONG).show();
        }           
        progress.dismiss();         
    }   
}
</code></pre>
