Q:

Android settext() from another class(not an activity) not working

I have a main Activity where I have a layout inflated.
I have a text view (textView)in the activity which I want to update from another class named 'Util.java' (this class does not extend anything, it is just a library class) where I have written methods common to the project for re usability).
Now on receiving a broadcast I update the text of the 'textView' by calling the method in Util.java using 'Util.setLoadingText(R.string.loadingText_creating_device);'
 public static void setLoadingText(int resId) {
    if (!Util.isNull(loadingText)) {
        Log.d(Util.TAG, LOG_LABEL + "SET TEXT CALLED:SHOW LOADING SCREEN" );
        loadingText.setText(resId);

    }
}

before calling the above method, I am calling 'Util.init(this)' in the onCreate of the main activity.below is the code for 
 public static void init(Activity activity) {
    activity.setContentView(R.layout.loading_screen);
    Log.d(Util.TAG, LOG_LABEL + "INIT CALLED:SHOW LOADING SCREEN" );
    loadingText = (TextView) activity.findViewById(R.id.loadingScreenTextView);
}

There are no compilation errors, but the 
  loadingText.setText(resId);

does not update the text.
Can anyone point out where I am going wrong? 

A:

you can't update things on the ui thread from anywhere but the ui thread, you need to use this .Where mAct is the main activity but you have to pass it in a parameter to the other class so it has access to it because it can't be a static reference
public static void updateText(Activity act, resID)
{

 loadingText = (TextView) activity.findViewById(R.id.loadingScreenTextView);
          act.runOnUiThread(new Runnable() 
                {
                     public void run() 
                     {
                       loadingText.setText(resID);

                     }

                });
}

