0

I am trying to send data through volly. I Write code and run that then the null point exception gives. i try a lot to search the solution but didnt find. Suggest me some solution.. Thanks in advance

Here is my code.

 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);

and this is the api code

$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();
Sohaib Raza
  • 41
  • 2
  • 10

0 Answers0