I have a problem in this code
The tv.setText(str);
is working and the text for tv
change to "LED1"
, but in if(str=="LED1")
it's not working! What is the problem?
Handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
byte [] data= (byte[]) msg.obj;
try {
tv.setText("");
String str = new String(data, "UTF-8");
tv.setText(str);
if(str=="LED1")
{
tv.setBackgroundColor(getResources().getColor(R.color.red));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
};