title: Android Back Action Button Result in App Crash
body: <p>I am building a new application which composed of 3 activities namely:
   - Splash Screen
   - Activity A
   - Activity B, and
   - Activity C</p>
  
  <p>From activity A user can go to both activities indicated below:</p>
  
  <p>A -> B -> C (from act A user can go to B then to C).
  A -> C (from act A user can go straight to C).
  B -> C (from B user can go to C).</p>
  
  <p>i also pass Serializable intent Extra between activities.</p>
  
  <p>The problem that i am having is whenever i pressed the back button on the Action Bar (Top Left Corner) it always makes my app crashes (Error: NULL Pointer Exception).</p>
  
  <p>I have tried to place this code on ALL of my activity.</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      this.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
  }
  </code></pre>
  
  <p>I tried to somehow mimic the physical backbutton behaviour since it is working when user press physical backbutton. But somewhat throws error as well.</p>
  
  <p>or</p>
  
  <pre><code>public void onBackPressed(){
    super.onBackPressed();
  }
  </code></pre>
  
  <p>or (well this one literally restart the app, which is discourage since it restart the app from splash screen).</p>
  
  <pre><code>public void onBackPressed(){
    super.onBackPressed();
    finish();
  }
  </code></pre>
  
  <p>Does anyone know the appropriate way to implement back button?</p>