I viewed the answer here: Updating Android UI using threads
But I am not able to understand how to instantiate the handler in the background thread to match the UiThread.
I just want to be clear and say that im using are 2 entirely separate classes.
UiThread Handler Code:
      final Handler handler = new Handler(){
      @Override
      public void handleMessage(Message msg) {
        if(msg.what==UPDATE_IMAGE){
          images.get(msg.arg1).setImageBitmap((Bitmap) msg.obj);
        }
        super.handleMessage(msg);
      }
    };
Background Thread Handler code:
    if(dataArrives){
        Message msg = handler.obtainMessage();
        msg.what = UPDATE_IMAGE;
        msg.obj = bitmap;
        msg.arg1 = index;
        handler.sendMessage(msg);
    }
In the background class, im getting "handler" as undefined. Please show the entire thread classes in your answer if you can.