private void getAsynHttp() {
OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder builder = new Request.Builder().url("http://193.112.100.126/json/kaoyaoshi/user_getUserOrderDetails.php");
builder.method("GET", null);
Request request = builder.build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (null != response.cacheResponse()) {
String str = response.cacheResponse().toString();
Log.i("lalalalala", "cache----" + str);
} else {
response.body().string();
String str = response.networkResponse().toString();
Log.i("lalalalala", "network-------" + str);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.i("lalalalala", "ok-------" );
Toast.makeText(getApplicationContext(),"请求成功", Toast.LENGTH_LONG).show();
}
});
}
});
}