The button is defined in the mainUI thread Here is the part of my code causing trouble-
button.setOnClickListener(new OnClickListener() {
public void onClick(View v){
new Thread(new Runnable() {
public void run() {
try {
OutputStream outToServer = client.getOutputStream();
DataOutputStream out = new DataOutputStream(outToServer);
out.writeUTF("Hello from " + client.getLocalSocketAddress());
final String msg = edi.getText().toString();
out.writeUTF("Client: " + msg);
runOnUiThread(new Runnable() {
@Override
public void run() {
tex.append(msg);
if (msg == "quit") {
button.setClickable(false);
tex.append("quitbutton");
}
tex.append("Client: " + msg + "\n");
edi.setText("");
}
});
} catch (Exception e) {
e.printStackTrace();
}
}}).start();
}
});
Rest of the code here is working perfectly fine. When I send in "quit" as string, the msg variable has it correctly. Problem seems not to be entering the if block at all, because if it did, it should have shown "quibutton" text in the textview, which it ain't.
I'd appreciate any kind of help, thanks :)
Edit- I didn't realize that I wasn't comparing the strings in the right way, not that I don't know how to. It probably got mixed up with C++ operator overloaded function in my head that I wanted to compare strings using == directly.