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(); }
慕斯4360584
慕斯4360584
慕慕5436299
相关分类