title: how to go to another activity in android if a condition is fulfilled?
body: <p>I am a beginner in android programming.</p>
  
  <p>I was making a quiz app in which I increase score if player answers correctly. If player answers wrong, I want to display game over screen with players final score. I used following code to update score and level with each correct answer and start GameOverActivity.java with a wrong answer:</p>
  
  <pre><code>boolean isCorrect(int answerGiven) {
      if (answerGiven == correctAnswer) {
          Toast.makeText(getApplicationContext(), "Well done!",
                  Toast.LENGTH_LONG).show();
          correctTrueOrFalse = true;
      } else {
          correctTrueOrFalse = false;
      }
      return correctTrueOrFalse;
  }
  
  void updateScoreAndLevel(int answerGiven) {
      if (isCorrect(answerGiven)) {
          for (int i = 1; i &lt;= currentLevel; i++) {
              currentScore = currentScore + i;
          }
          currentLevel++;
      }
      else {
          Intent k = new Intent (GameActivity.this, GameOverActivity.class); //#######
          startActivity(k); 
      }
  }
  </code></pre>
  
  <p>But whenever I run this app, the scores and level are successfully updated with each correct answer, but as soon as I give a wrong answer, the app crashes and fails to start GameOverActivity.class (code for the game over screen).</p>
  
  <p>My GameOverActivity file seems to be fully correct and I feel problem is in the <code>######</code> marked line. Please help me figure out the problem.</p>
  
  <p><strong>edit</strong>: my manifest file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
          android:screenOrientation="portrait"
      &lt;/activity&gt;
      &lt;activity android:name=".GameActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"&gt;
          android:screenOrientation="portrait"
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>yes, i see my GameOverActivity file is not registered in manifest. i thought android studio auto registers files in manifest. so how to register it? remember i have intents in both GameActivity and GameOverActivity files so manifest might have to be changed accordingly.</p>