title: Android App crashing when opening a new intent
body: <p>I'm new to to android programming. I've been using eclipse and trying to develop a two player tic tac toe game, but the app keeps crashing whenever a player wins. I try to open a new activity - a dialog saying player x wins and two buttons saying play again or exit. PlayerOne and PlayerTwo classes just sets the content view to the dialogs. I tried putting try and catch around the startActivity methods but then nothing happens I get three X's or O's in a row, the game just keeps running without any dialogs showing. So can anyone help me? Here is me code:</p>
  
  <pre><code>package com.rohan.tictactoe;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  public class Main extends Activity implements OnClickListener{
      Button t1,t2,t3,t4,t5,t6,t7,t8,t9;
      int turn = 1;
      int status = 0;
      String s1,s2,s3,s4,s5,s6,s7,s8,s9 = "";
      Intent i = new Intent("com.rohan.tictactoe.PlayerOne");
     Intent x = new Intent("com.rohan.tictactoe.PlayerTwo");
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         initiallize();
     }
  
     @Override
     public void onClick(View v) {
         switch(v.getId()){
         case R.id.t1:
              if (turn ==1){
              t1.setText("X");
              turn =2;
              s1 = "X";
              }
          else if(turn == 2){
              t1.setText("O");
              turn =1;
              s1= "O";
          }
          winner();
          break;
      case R.id.t2:
          if (turn ==1){
              t2.setText("X");
              turn =2;
              s2 = "X";
          }
          else if(turn == 2){
              t2.setText("O");
              turn =1;
              s2 = "O";
          }
          winner();
          break;
      case R.id.t3:
          if (turn ==1){
              t3.setText("X");
              turn =2;
              s3 = "X";
          }
          else if(turn == 2){
              t3.setText("O");
              turn =1;
              s3 = "O";
          }
          winner();
          break;
      case R.id.t4:
          if (turn ==1){
              t4.setText("X");
              turn =2;
              s4 = "X";
              t4.setEnabled(false);
          }
          else if(turn == 2){
              t4.setText("O");
              turn =1;
              s4 = "O";
              t4.setEnabled(false);
          }
          winner();
          break;
      case R.id.t5:
          if (turn ==1){
              t5.setText("X");
              turn =2;
              s5 = "X";
              t5.setEnabled(false);
          }
          else if(turn == 2){
              t5.setText("O");
              turn =1;
              s5 = "O";
              t5.setEnabled(false);
          }
          winner();
          break;
      case R.id.t6:
          if (turn ==1){
              t6.setText("X");
              turn =2;
              s6 = "X";
              t6.setEnabled(false);
          }
          else if(turn == 2){
              t6.setText("O");
              turn =1;
              s6 = "O";
              t6.setEnabled(false);
          }
          winner();
          break;
      case R.id.t7:
          if (turn ==1){
              t7.setText("X");
              turn =2;
              s7 = "X";
              t7.setEnabled(false);
          }
          else if(turn == 2){
              t7.setText("O");
              turn =1;
              s7 = "O";
              t7.setEnabled(false);
          }
          winner();
          break;
      case R.id.t8:
          if (turn ==1){
              t8.setText("X");
              turn =2;
              s8 = "X";
              t8.setEnabled(false);
          }
          else if(turn == 2){
              t8.setText("O");
              turn =1;
              s8 = "O";
              t8.setEnabled(false);
          }
          winner();
          break;
      case R.id.t9:
          if (turn ==1){
              t9.setText("X");
              turn =2;
              s9 = "X";
              t9.setEnabled(false);
          }
          else if(turn == 2){
              t9.setText("O");
              turn =1;
              s9 = "O";
              t9.setEnabled(false);
          }
          winner();
          break;
      }
  
  }
  public void winner(){
      if (s1 == s2 &amp;&amp; s2 == s3 &amp;&amp; s3 =="X"){
          startActivity(i);
      }
      else if(s1 == s2 &amp;&amp; s2 == s3 &amp;&amp; s3 =="O"){
          startActivity(x);
      }
      else if(s4 == s5 &amp;&amp; s5 == s6 &amp;&amp; s6 =="X"){
          startActivity(i);
      }
      else if(s4 == s5 &amp;&amp; s5 == s6 &amp;&amp; s6 =="O"){
          startActivity(x);
      }
      else if(s7 == s8 &amp;&amp; s8 == s9 &amp;&amp; s9 =="X"){
          startActivity(i);
      }
      else if(s7 == s8 &amp;&amp; s8 == s9 &amp;&amp; s9 =="O"){
          startActivity(x);
      }
      else if(s1 == s4 &amp;&amp; s4 == s7 &amp;&amp; s7 =="X"){
          startActivity(i);
      }
      else if(s1 == s4 &amp;&amp; s4 == s7 &amp;&amp; s7 =="O"){
          startActivity(x);
      }
      else if(s2 == s5 &amp;&amp; s5 == s8 &amp;&amp; s8 =="X"){
          startActivity(i);
      }
      else if(s2 == s5 &amp;&amp; s5 == s8 &amp;&amp; s8 =="O"){
          startActivity(x);
      }
      else if(s3 == s6 &amp;&amp; s6 == s9 &amp;&amp; s9 =="X"){
          startActivity(i);
      }
      else if(s3 == s6 &amp;&amp; s6 == s9 &amp;&amp; s9 =="O"){
          startActivity(x);
      }
      else if(s1 == s5 &amp;&amp; s5 == s9 &amp;&amp; s9 =="X"){
          startActivity(i);
      }
      else if(s1 == s5 &amp;&amp; s5 == s9 &amp;&amp; s9 =="O"){
          startActivity(x);
      }
      else if(s3 == s5 &amp;&amp; s5 == s7 &amp;&amp; s7 =="X"){
          startActivity(i);
      }
      else if(s3 == s5 &amp;&amp; s5 == s7 &amp;&amp; s7 =="O"){
          startActivity(x);
      }else{
  
      }
  
  }
  
  public void initiallize(){
      t1 = (Button) findViewById(R.id.t1);
      t2 = (Button) findViewById(R.id.t2);
      t3 = (Button) findViewById(R.id.t3);
      t4 = (Button) findViewById(R.id.t4);
      t5 = (Button) findViewById(R.id.t5);
      t6 = (Button) findViewById(R.id.t6);
      t7 = (Button) findViewById(R.id.t7);
      t8 = (Button) findViewById(R.id.t8);
      t9 = (Button) findViewById(R.id.t9);
  
      t1.setOnClickListener(this);
      t2.setOnClickListener(this);
      t3.setOnClickListener(this);
      t4.setOnClickListener(this);
      t5.setOnClickListener(this);
      t6.setOnClickListener(this);
      t7.setOnClickListener(this);
      t8.setOnClickListener(this);
      t9.setOnClickListener(this);
   }
  
  
  }
  </code></pre>