title: using onClickView to call another class
body: <p>I want to use a button click to pass selection parameters to another class that will build a map screen using the passed parameters. I am focused on getting my button action working. I a using onCLickListener and onCLickView as follows</p>
  
  <pre><code>Class1:
  
  public class Class1  extends Activity implements OnClickListener {
  
      Class2 class2;
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  ..........
  
         Button button = (Button)findViewById(R.id.btn_configup1);
          button.setOnClickListener(this);        
     }
  
      public void onClick(View v) {
          Class2 class2 = new Class2();
          //Save state.. selections and params and use bundle
          //to pass into class2
          class2.execMapBuild();
  
      }    
  
  
  }
  
  
  Class2:
  </code></pre>
  
  <p>public class Class2 extends MapActivity { </p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.drawable.navup);
  }
  
  
  public void execMapBuild() {    
          finish(); //just in case we return.
          Intent intent = new Intent(CLass2.this, Class2.class);
          startActivity(intent);
  
      }
  </code></pre>
  
  <p>I have everything working except the desired button action. I want the button click in Class1.onVlickView  to call Class2.execMapBuild using the button click action. I have the button click capturing the action and calling the execMapBuild method on Class2. But I get a NullPointerException as it moves from startActivity(intent) into onCreate.</p>
  
  <p>I have tried several other ways of nailing this down, but this seems the best and I seem close to figuring it out. I would really appreciate an explanation of what I may be missing.
  Added code that was initially not copied in.</p>