@Override
public void run() {
try {
while(true){ //无限循环来监听客户端是否有数据过来
if (msg!=null) {
try {
JSONArray jsonObjs = new JSONArray(msg);
Log.i("TService", "===============>aaaaa");
for(int i=0;i<jsonObjs.length();i++){ //for循环读取客户端传过来的数据
JSONObject jsonobj=(JSONObject) jsonObjs.get(i);//转成Object
CmdType=jsonobj.getString("CmdType");
CmdCode=jsonobj.getInt("CmdCode");
CmdParam1=(float) jsonobj.getDouble("CmdParam1"); //读取数值强制转换成float
CmdParam2=(float) jsonobj.getDouble("CmdParam2");
CmdParam3=jsonobj.getInt("CmdParam3");
Log.i("TService", CmdType);
}
Log.i("TService", "==========>cccc");
if (CmdType==KEY) {
Log.i("TService", "==========>bbb");
try {
Instrumentation instrumentation=new Instrumentation();
instrumentation.sendKeyDownUpSync(CmdCode);
} catch (Exception e) {
e.printStackTrace();
}
} else if (CmdType==TOUCH) {
Log.i("TService", "==========>dd");
try {
Instrumentation ins=new Instrumentation();
ins.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), CmdCode, CmdParam1, CmdParam2, CmdParam3));
} catch (Exception e) {
e.printStackTrace();
}
}
else {
}
} catch (Exception e) {
e.printStackTrace();
}
}
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
这是代码log也只打印到===========>cccc 之后的if开始怎么就不执行了呢 这到底是怎么回事啊 求帮忙看看啊 真心谢谢了
java中字符串比较,使用equals方法