As the title says, I'm having trouble when updating the contents on my Textview. It all works well, until I change the orientation.
Here is the onCreate of the Activity that holds the Textview:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.transacao);
screenTextView = (TextView) findViewById(R.id.lblStatusTrn);
screenTextView.setText(screenMessage);
//...
}
And here is the code that update the Textview:
private void setScreenMessage(String message) {
screenMessage = message;
screenTextView = (TextView) findViewById(R.id.lblStatusTrn);
screenTextView.setText(screenMessage);
}
Even though I keep getting no errors, the Textview doesn't update after I call setScreenMessage. This all happens after the orientation change. If I don't change the orientation, everything works fine.
I already looked into a number of similar questions here, but none of them seemed to work for me.
EDIT 1: I don't know if it is relevant, but the setScreenMessage is called from another thread, through an Handler. Code for the Handler:
public void handleMessage(android.os.Message message) {
//...
// This command calls setScreenMessage
command.execute();
}
EDIT 2: Apparently, using Broadcast did the trick. But that makes me think if it is possible that I had an valid reference to an Activity, even though it is not this reference that is been shown. If that is the case, I might have a useless reference stealing away my memory. Is it possible? Is there a way to check this?