Android async image load
<p>So I have an activity with an ImageView. My goal is to have the activity start and asynchronously fetch the image I need in there. While the image is being fetched, I'd like to display some sort of spinning loading symbol in place of the image. I've tried using AsyncTask as a separate class, but ran into issues relating to modifying the views of another activity. I tried an anonymous Runnable class inside the activity, but it doesn't seem to be yielding the effects I expect. Can anyone advise?</p>

<p>SOLVED: Simply needed a handler in the activity</p>

<pre><code>    final Handler handler = new Handler() {
          public void  handleMessage(Message msg) {
              ImageView qrCode =  (ImageView)findViewById(R.id.qr); 
              qrCode.setImageBitmap((Bitmap)msg.obj);
          }
     };


    new Thread(new Runnable(){

            public void run() {
                BitmapFactory.Options bmOptions;
                bmOptions = new BitmapFactory.Options();
                bmOptions.inSampleSize = 1;
                int retry = 0;
                Bitmap bm = null;
                while(retry &lt; 50 &amp;&amp; bm == null){
                    bm = LoadImage(image_URL, bmOptions);
                    if(bm == null){
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                    retry++;
                }
                Message msg = new Message();
                msg.obj = bm;
                handler.sendMessage(msg);
                return;
            } 


    }).start();
    `
</code></pre>
