首页 > 解决方案 > 使用 Log for Volley Post 方法

问题描述

我正在使用 Post 方法将数据发送到服务器,并且数据包括字符串和图像值图像值是通过多部分发送的,现在我遇到了一些错误,我想在日志中发布我的所有数据以查看数据无法发送到的位置发送任何人都可以帮助我为所有参数值使用日志,包括日志中的图像字符串值

后方法示例

 private void new_processing() {
        String URL = "Url";
        VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(Request.Method.POST, URL,
                new Response.Listener<NetworkResponse>() {
                    @Override
                    public void onResponse(NetworkResponse response) {
                        Log.d("response", new String(response.data));
                        rQueue.getCache().clear();
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }) {


            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
                    if (action_taken == "Sample Taken " ||action_taken.equals("Sample Taken ")) {
                    JSONObject json2 = new JSONObject();
                    try {
                        json2.put("sampletype", product_type);
                        json2.put("samplecode", sample_code);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    JsonArray sample_obj = new JsonArray();
                    sample_obj.add(String.valueOf(json2));
                    params.put("Raid_Sample", sample_obj.toString());
                    params.put("Raid_Action", null);



                } else if (action_taken.equals("Sale Stoped") || action_taken.equals("Licence Cancelled") ||action_taken == ("Licence Cancelled") || action_taken.equals("Licence Suspended")) {
                    JSONObject json2 = new JSONObject();
                    try {
                        json2.put("actiontype", action_taken);
                        json2.put("actiondate", lic_date);
                        json2.put("letterno", lic_letter);
                        json2.put("copyno", lic_copy);

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


                    params.put("Raid_Action", String.valueOf(json2));


                    params.put("letterfile", image_letter);
                    Log.i("action_object", String.valueOf(json2));
                }

                params.put("AuthID", AuthId);
                params.put("producttype", product_type);

                /* params.put("raidother", raid_type_other);
                params.put("violationother", voilation_other);*/
                params.put("dateofraid", raid_date);
                params.put("locationname", location_name);
                params.put("locationaddress", location_address);


                JSONArray array;
                array = new JSONArray();
                for (int i = 0; i < movieList1.size(); i++) {
                    JSONObject movieObject = new JSONObject();

                    try {
                        movieObject.put("name", movieList1.get(i).getName());
                        movieObject.put("designation", movieList1.get(i).getDesignation());
                        movieObject.put("postingplace", movieList1.get(i).getPostingplace());
                        array.put(movieObject);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                memberlist = String.valueOf(array);
                Log.i("arraylist", memberlist.toString());
                params.put("Raid_Team", memberlist);

                return params;
            }

            @Override
            protected Map<String, DataPart> getByteData() {
                Map<String, DataPart> params = new HashMap<>();
                long imagename = System.currentTimeMillis();
                params.put("picurl1", new DataPart(imagename + ".jpge", getFileDataFromDrawable(bitmap)));

                return params;
            }
        };


        volleyMultipartRequest.setRetryPolicy(new DefaultRetryPolicy(
                0,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        rQueue = Volley.newRequestQueue(ScrollingActivity.this);
        rQueue.add(volleyMultipartRequest);


    }

标签: androidandroid-studio

解决方案


推荐阅读