title: Android volley token changes every request
body: <p>I want to get the results about imei adresses after my inquiry on the inquiry site. The site has token input during the query and I can get this token as follows. But when i run the second volley queue i soppose the token changes and the result doesn't come. How can I solve this problem. The site that i questioned the imei adress and my codes are below. </p>
  
  <pre><code>package com.myapp.query;
  
  import com.android.volley.Request;
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.android.volley.toolbox.Volley;
  import android.os.Bundle;
  import android.widget.Toast;
  
  import java.io.UnsupportedEncodingException;
  import java.net.URLEncoder;
  import java.util.HashMap;
  import java.util.Map;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  public class imeiSorgulama extends AppCompatActivity {
  
      StringRequest stringRequest;
      RequestQueue queue;
      String token, tag, value, tag2, value2, result;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_imei_sorgulama);
  
          queue = Volley.newRequestQueue(this);
  
          final String url = "https://www.turkiye.gov.tr/imei-sorgulama";
  
          stringRequest = new StringRequest(Request.Method.GET, url,
  
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
  
                          tag     =  "&lt;input type=\"hidden\" name=\"token\" value=\"";
                          value   = response.substring(response.indexOf(tag) + tag.length());
  
                          token  = value.substring(0, value.indexOf("\""));
  
                          try {
                              token = URLEncoder.encode(token,"UTF-8");
                          } catch (UnsupportedEncodingException e) {
                              e.printStackTrace();
                          }
  
                          imeiQuery();
  
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          Toast.makeText(imeiSorgulama.this, error+"", Toast.LENGTH_SHORT).show();
  
                      }
                  }
          );
          queue.add(stringRequest);
      }
  
      private void imeiQuery() {
  
          final String url = "https://www.turkiye.gov.tr/imei-sorgulama?submit";
  
          stringRequest = new StringRequest(Request.Method.POST, url,
                  new Response.Listener&lt;String&gt;()
                  {
                      @Override
                      public void onResponse(String response) {
  
                          tag2     =  "&lt;dl class=\"compact\"&gt;";
                          value2   = response.substring(response.indexOf(tag2) + tag2.length());
                          result  = value2.substring(0, value2.indexOf("&lt;/dl&gt;"));
  
                          Toast.makeText(imeiSorgulama.this, result+"", Toast.LENGTH_SHORT).show();
                      }
                  },
                  new Response.ErrorListener()
                  {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          Toast.makeText(imeiSorgulama.this, error+"", Toast.LENGTH_SHORT).show();
                      }
                  }
          ) {
              @Override
              protected Map&lt;String, String&gt; getParams()
              {
                  Map&lt;String, String&gt;  params = new HashMap&lt;String, String&gt;();
                  params.put("txtImei", "545454545454545");
                  params.put("token=", token);
  
                  return params;
              }
  
          };
          queue.add(stringRequest);
      }
  
  
  }
  </code></pre>