android-async-http post request with body

后端 未结 2 1401
囚心锁ツ
囚心锁ツ 2020-12-22 04:01

It\'s require to realize a function that user can send feedback to the server in the app.And I use the asynchttpclient in the app.But I don\'t know how to do this.anyont kn

2条回答
  •  遥遥无期
    2020-12-22 04:11

        AsyncHttpClient client = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("key", value);
        client.post(context, URL_YOURURL,
                params, new AsyncHttpResponseHandler() {
    
            Progress pd = new Progress(context);
    
    
                    public void onStart() {
    
                        super.onStart();
                        pd.show();
    
                    }
    
                    @Override
                    public void onSuccess(int arg0,
                            Header[] arg1, byte[] arg2) {
    
    
    
                        try {
                            JSONObject json = new JSONObject(
                                    new String(arg2));
    
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
    
                    }
    
                    @Override
                    public void onFailure(int arg0,
                            Header[] arg1, byte[] arg2,
                            Throwable arg3) {
    
    
                    }
    
                    public void onFinish() {
                        super.onFinish();
                        if(pd!=null){
                            pd.dismiss();
                        }
    
    
    
                    }
                });
    
    
    }
    

    I think You are asking for this example.

提交回复
热议问题