• 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());
           }
    
    
        }
    }
    
    
    
    
  • 相关阅读:
    一个不错的资源共享微盘
    LUA upvalue使用陷阱一例
    安卓破解视频教程合集
    开发Android逆向工具
    手机上编程,编写android apk
    smail修改字符串 汉字
    Android logcat命令详解
    protobuf
    Android Rxjava
    butterknife
  • 原文地址:https://www.cnblogs.com/c-x-a/p/14756734.html
Copyright © 2020-2023  润新知