android使用AsyncHttpClient发送请求

package com.example.xxxx;

import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import cz.msebera.android.httpclient.Header;

public class HttpClient {

    public static void senddata(String data) {

        String postUrl = "http://xxx:9091/get_video_list";

        RequestParams params = new RequestParams();
        params.put("data", data);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        try {
            asyncHttpClient.post(postUrl, params, new AsyncHttpResponseHandler() {
               @Override
               public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                   Log.d("cxa", new String(responseBody));

               }

               @Override
               public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                   Log.d("cxa",error.getMessage());

               }

           });
       }
       catch (Exception e){
           Log.d("cxa",e.getMessage());
       }


    }
}



android使用AsyncHttpClient发送请求

上一篇:安卓调用WebView中的js字符串生成工具


下一篇:unity3D 2D游戏启动游戏后怪物不移动的bug解决方案