title: Sending values to the server using json Array
body: <p>i need to send some values to the server using the android volley library. But I'm unable to send the values in the JSON array format. I have tried many tutorials but i couldn't get any solution for sending JsonArray. Please give me a solution .</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  public Button button;
  public String Url = "http://www.apsox.com/appdata/communication/createlocksviamobileapp";
  public static String TAG = MainActivity.class.getSimpleName();
  public String jsonResponse;
  public static TextView txtResponse;
  public String JsonString = "";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      button = (Button) findViewById(R.id.button);
  
      txtResponse = (TextView) findViewById(R.id.textView);
  
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              makeJsonArrayRequest();
          }
      });
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();
          }
      });
  }
  
  
  public void makeJsonArrayRequest() {
      RequestQueue requestQueue = Volley.newRequestQueue(this);
      JSONArray jsonArray = new JSONArray();
  
      try {
          JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.POST, Url, jsonArray, new Response.Listener&lt;JSONArray&gt;() {
              @Override
              public void onResponse(JSONArray response) {
  
                  txtResponse.setText(response.toString());
              }
  
          }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  txtResponse.setText(error.toString());
              }
          }) {
              @Override
              public Map&lt;String, String&gt; getParams() {
                  Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
                  params.put("lock_name", "testing");
                  params.put("lock_code", "2222287776554");
                  params.put("details", "this is a testing lock");
                  params.put("owner_userid", "1");
                  params.put("master_security_phone", "Not Set");
                  params.put("master_security_code", "Not Set");
                  params.put("remote_lock_access_code", "1234");
                  return params;
              }
          };
          requestQueue.add(jsonArrayRequest);
      } catch (JsonIOException e) {
          e.printStackTrace();
      }
  
  
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>