Reputation: 1851
I am creating a Handler
but for some reason the if statement
does not trigger
. The Log is printing out the correct value right before the if statement
.
mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
String s=(String)msg.obj;
s = s.trim();
Log.v("mHandler reply", s);
if(s == "OK"){
Dialog.dismiss();
}
}
};
Here is the log
03-24 09:02:53.707: V/mHandler reply(7331): OK
Why is this not working?
Upvotes: 0
Views: 57
Reputation: 9700
Use equals()
method instead of ==
operator for String
comparison as follows...
if(s.equals("OK")){
Dialog.dismiss();
}
To get more information check How do I compare strings in Java?
Upvotes: 2