AsyncHttpClient

网络请求方式


  //创建网络请求对象

        AsyncHttpClient client = new AsyncHttpClient();
        //接口地址
        String url = "http://mock.eoapi.cn/success/LISNRPQd9eVEpj1qFQlh5h5EJDKAVQJJ";
        client.get(this, url, new TextHttpResponseHandler() {
            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                Toast.makeText(AsyncHttpClientActivity.this, "请求数据失败", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onSuccess(int statusCode, Header[] headers, String responseString) {
                Toast.makeText(AsyncHttpClientActivity.this, "请求成功:" + responseString.toString(), Toast.LENGTH_SHORT).show();

            }
        });

你可能感兴趣的:(AsyncHttpClient)