private void login() {
new Thread(new Runnable() {
@Override
public void run() {
try {
Response result = HttpUtil.sendOkHttpRequest(address);
if (result != null) {
String responseDta = Objects.requireNonNull(result.body()).string();
JsonParser parser = new JsonParser();
JsonObject jsonObject = parser.parse(responseDta).getAsJsonObject();
JsonObject msg = jsonObject.get("responseDta").getAsJsonObject();
System.out.println(msg.get("responseDta"));
//判断登录成功还是失败,并向主线程传递数据
if ("success".equals(msg)) {
Message message = new Message();
message.what = 1;
message.obj = msg;
handler.sendMessage(message);
} else {
Message message = new Message();
message.what = 2;
message.obj = msg;
handler.sendMessage(message);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
目前暂无任何回答
- 0 回答
- 0 关注
- 819 浏览
添加回答
举报
0/150
提交
取消