OkHttpClient mClient = new OkHttpClient();
Request mRequest = new Request.Builder()
.url("http://192.168.199.110:8080/mockjs/1/getLoadingSheetList?")
.build();
mClient.newCall(mRequest).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
Gson gson = new Gson();
String result = response.body().string();
Log.e("message", result);
mJsonDriver = new JsonDriver();
mJsonDriver = gson.fromJson(result, JsonDriver.class);
final int count = mJsonDriver.getCount();
Log.e("message2", String.valueOf(count));
final String endStation = mJsonDriver.getDataList().get(0).getEndStation();
Log.e("message2", endStation);
runOnUiThread(new Runnable() {
@Override
public void run() {
mTextView.setText(endStation);
}
});
}
});
OkHttp + Gson
最新推荐文章于 2024-06-15 17:48:47 发布