title: Passing a string or a variable from a dialoguebox to an activity Android
body: <p>I wan to implicitly pass two string or variable from a dialoguebox  to be used by another activity and at the same time opening that activity.</p>
  
  <p>dialoguebox</p>
  
  <pre><code>String city = addresses.get(0).getLocality();
  String category = "Hazard";
  
              AlertDialog.Builder prompt = new  
               AlertDialog.Builder(MapsActivity.this);
              prompt.setCancelable(false)
                      .setPositiveButton("Mineralization", new 
               DialogInterface.OnClickListener() {
  
                      .setPositivetiveButton("Geohazard", new 
                             DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, 
                                  int which) {
  
                                      startActivity(new  
                          Intent(getApplicationContext(),MapsActivity.class));
  
                          //i want to pass the String city and category here
                                  }
                              }
                      )
  
  
  
  
  
              AlertDialog alert = prompt.create();
              alert.setTitle("Please select an option");
              alert.show();
  
              TextView myTextView = (TextView) findViewById(R.id.PSString);
              myTextView.setText(city);
  </code></pre>
  
  <p>New activity</p>
  
  <pre><code>package com.example.boneyflesh.homepage;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  public class GeohazardResults extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_geohazard_results);
      }
  }
  </code></pre>
  
  <p>how do i do this? what do i write on the onClickListener and what do i do on the new activity so that i can get the strings?</p>