Android : how to use bluetooth read String [duplicate]

on Thursday, August 21, 2014



This question already has an answer here:




I modify android bluetooth chat sample source code , then I want to read Sting like "BT1051", so I modify source code :MainActivity.java



private final Handler mHandler = new Handler(){
public void handleMessage(Message msg){
switch(msg.what){
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
String readMessage = new String(readBuf, 0, msg.arg1);
if(readMessage=="BT1051"){
digitalInBtn.setChecked(false);
}else
digitalInBtn.setChecked(true);
}
break;
}


}


and my digitalInBtn is ToggleButton . It's not working?somebody help?


0 comments:

Post a Comment