title: How to send response of a volley POST request called from one activity to another in android
body: <p>Requirement:
  In Android app code, in MainActivity, I want to call a REST POST API through Volley and then pass the JSON response as it is in next Activity. But the response which gets passed is blank. The code is:</p>
  <p>Please note that</p>
  <p>System.out.println(globalOutput); //THIS DOESN'T PRINT ANYTHING</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
      public static final String LOGIN_RESULT = &quot;com.example.awgpusers2.loginResult&quot;;
      static String globalOutput;
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      public void login(View view) throws Exception {
          EditText emailEditText = findViewById(R.id.editTextTextEmailAddress2);
          EditText phoneEditText = findViewById(R.id.editTextPhone2);
          EditText passwordEditText = findViewById(R.id.editTextTextPassword);
  
          String emailAddress = emailEditText.getText().toString();
          String phone = phoneEditText.getText().toString();
          String password = passwordEditText.getText().toString();
          
          makePostCall(emailAddress, phone, password, new VolleyCallback() {
              @Override
              public void onSuccess(String result) {
                  System.out.println(&quot;result &quot; + result);
                  globalOutput = result;
  
                  System.out.println(&quot;globalOutput &quot; + globalOutput);
                             }
          });
          System.out.println(globalOutput); //THIS DOESN'T PRINT ANYTHING
          
          Intent intent = new Intent(this, LoginNextActivity.class);
          intent.putExtra(LOGIN_RESULT, globalOutput);
          startActivity(intent);
      }
  
      void makePostCall(String emailAddress, String phone, String password, final VolleyCallback callback) throws Exception {
          //String globalOutput;
          String postUrl = &quot;http://18.188.180.148:8080/auth/login&quot;;
          RequestQueue requestQueue = Volley.newRequestQueue(this);
  
          JSONObject postData = new JSONObject();
          try {
              postData.put(&quot;email&quot;, emailAddress);
              postData.put(&quot;password&quot;, password);
              postData.put(&quot;phoneNumber&quot;, phone);
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, postUrl, postData, new Response.Listener&lt;JSONObject&gt;() {
              @Override
              public void onResponse(JSONObject response) {
                  
                  callback.onSuccess(response.toString());
              }
          }, new Response.ErrorListener() {
     ........................
       });
  
          requestQueue.add(jsonObjectRequest);
  
      }
  }
  </code></pre>
  <p>Please help</p>