通过volly发送邮件请求时出现空点异常

时间:2015-11-09 11:11:33

标签: php android android-volley

我正试图通过volly发送数据。我编写代码然后运行,然后null点异常给出。 我尝试了很多搜索解决方案,但没有找到。建议我一些解决方案.. 提前致谢

这是我的代码。

 StringRequest stringRequest=new StringRequest(Request.Method.POST, url,
                    new Response.Listener<String>() {
                        @Override
                        public void onResponse(String responc) {
                            Toast.makeText(getApplicationContext(),responc,Toast.LENGTH_LONG).show();

                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {

                    Log.d("Error", "error");
                }
            })
            {

                @Override
                protected Map<String, String> getParams() throws AuthFailureError {
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("name","rumeel");
                    params.put("age","23");
                    params.put("gender", "male");
                    params.put("beaconId", "32413");
                    return params;
                }
            };
            application.getInstance().addToRequesstQue(stringRequest);

这是api代码

$application->post('/register', function() use($application)
   {

    $user_name=$application->request->post('name');
    $user_age=$application->request->post('age');
    $gender=$application->request->post('gender');
      $beacon_id=$application->request->post('beaconId');


   $db=new dbHandler();
   $result=$db->enterUserDetail($user_name,$user_age,$gender,$beacon_id);

   if($result)
     {
       $responce["error"]=false;
       $responce["status"]="Data enter successful";
     }else
        {
          $responce["error"]=true;
           $responce["status"]="Data not enter";

         }

       echo json_encode($responce);
        });



      $application->run();

0 个答案:

没有答案