在android中通过截击发送post请求

yjghlzjz  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(214)

我需要发送一个邮寄请求到http://localhost:8080/login 但是,我需要再添加两个参数,如下所示:http://localhost:8080/login/user/pass 例子:http://localhost:8080/login/hello/world 有人能帮我吗?非常感谢。代码如下:

// Instantiate the RequestQueue.
                RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
                String url ="http://localhost:8080/login";
                // Request a string response from the provided URL.
                StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                        new Response.Listener<String>() {
                            @Override
                            public void onResponse(String response) {
                                // Display the first 500 characters of the response string.
                                System.out.println("USPESNO");
                                try {
                                    JSONObject objresponse = new JSONObject(response);
                                    System.out.println(objresponse);
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                                Intent i = new Intent(LoginActivity.this,MainActivity.class);
                                startActivity(i);
                            }
                        }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        System.out.println("NEUSPESNO");
                        Toast.makeText(LoginActivity.this,"Pogresni podaci",Toast.LENGTH_LONG);
                    }
                }){
                    @Override
                    protected Map<String,String> getParams(){
                        Map<String,String> params = new HashMap<String,String>();
                        params.put("/",username);
                        params.put("/",password);
                        return params;

                    }
                };
                // Add the request to the RequestQueue.
                queue.add(stringRequest);

**

logcat

2021-07-08 12:59:25.797 4273-28654/com.google.android.googlequicksearchbox W/ErrorProcessor: onFatalError, processing error from engine(4)
     com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream
         at com.google.android.apps.gsa.staticplugins.microdetection.d.k.a(SourceFile:91)
         at com.google.android.apps.gsa.staticplugins.microdetection.d.l.run(Unknown Source:14)
         at com.google.android.libraries.gsa.runner.a.a.b(SourceFile:32)
         at com.google.android.libraries.gsa.runner.a.c.call(Unknown Source:4)
         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
         at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
         at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
         at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
         at java.lang.Thread.run(Thread.java:764)
         at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
      Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
         at com.google.android.apps.gsa.speech.audio.Tee.j(SourceFile:103)
         at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2)
         at java.io.InputStream.read(InputStream.java:101)
         at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:17)
         at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
         at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) 
         at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
         at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4) 
         at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
         at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
         at java.lang.Thread.run(Thread.java:764) 
         at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6) 

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题