Here is my code
this is my InstantMessage application
the method processMessage will automatically do when the applicaiton have new message
My problem is the textview not work when method processMessage do but when i send message when textview update by both use the same updateChat method
@Override
public void onClick(View v) {
String message = text.getText().toString();
try {
Log.e("On Click", message + " : " + contact);
chat.sendMessage(message);
message = username + " : " + message;
updateChat(message);
} catch (XMPPException e) {
e.printStackTrace();
}
}
public void updateChat(String message){
chatLog += message + "\n";
chatBox.setText(chatLog);
}
@Override
public void processMessage(org.jivesoftware.smack.Chat arg0, Message arg1) {
String temp = InstantMessage.usernameCutter(arg0.getParticipant()) + " : "+ arg1.getBody();
Log.e("ChatPage ", "ProcessMessage");
updateChat(temp);
}
Are processMessage method running on UI thread?
if not, use this construction