title: What differs Up Button to Back Button? And how to make Up Button work like Back Button?
body: <p>In terms of how each button treat the activities? What are the differences?</p>
  
  <p>I have 3 activities (let's call them A, B, and C). A is B's parent and B is C's parent, and one intent take a extra to the the next activity. I go from A to B and then B to C. When I try to go back using Up Button, the app crashes, and that's because it tries to get a info from the extra in the intent.</p>
  
  <p>But when I use Back Button, it works (???) and I don't know why.</p>
  
  <p>I tried to make Up Button work like Back Button, doing the following:</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()){
          case R.id.home:
              onBackPressed();
              break;
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>and also tried using <code>NavUtils.navigateUpFromSameTask(this)</code> but it's not working either. How can I solve it?</p>
  
  <p><strong>Edit: error Log</strong></p>
  
  <pre><code>2019-01-09 03:45:43.468 29326-29326/com.jvponte.maosdadasv1 E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.jvponte.maosdadasv1, PID: 29326
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jvponte.maosdadasv1/com.jvponte.maosdadasv1.UserActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.jvponte.maosdadasv1.User.getUsername()' on a null object reference
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
      at android.app.ActivityThread.-wrap11(Unknown Source:0)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:169)
      at android.app.ActivityThread.main(ActivityThread.java:6568)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.jvponte.maosdadasv1.User.getUsername()' on a null object reference
      at com.jvponte.maosdadasv1.UserActivity.onCreate(UserActivity.java:67)
      at android.app.Activity.performCreate(Activity.java:7016)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
      at android.app.ActivityThread.-wrap11(Unknown Source:0) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
      at android.os.Handler.dispatchMessage(Handler.java:105) 
      at android.os.Looper.loop(Looper.java:169) 
      at android.app.ActivityThread.main(ActivityThread.java:6568) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
  </code></pre>
  
  <p><strong>Edit: some more code</strong>
  I have this in <code>onCreate()</code> on my activity B (<code>UserActivity</code>). The intent extra is added on activity A</p>
  
  <pre><code>    Intent intent = getIntent();
  
      if(intent.hasExtra("clickedUser")){
          mOtherUser = intent.getParcelableExtra("clickedUser");
      }
      if(intent.hasExtra("loggedUser")){
          mLoggedUser = intent.getParcelableExtra("loggedUser");
      }
  
      /.../
  
      mUsernameTV.setText(mOtherUser.getUsername());
      mUserInfoTV.setText(mOtherUser.getUserInfo());
  </code></pre>
  
  <p>Here I call activity C (<code>ChatActivity</code>)</p>
  
  <pre><code>Intent intent = new Intent(UserActivity.this, ChatActivity.class);
  intent.putExtra("loggedUser", mLoggedUser);
  intent.putExtra("clickedUser", mOtherUser);
  startActivityForResult(intent, RC_CHAT);
  </code></pre>
  
  <p>In <code>ChatActivity</code> <code>onCreate()</code> I have this</p>
  
  <pre><code>    Intent intent = getIntent();
      if (intent.hasExtra("clickedUser")){
          otherUser = intent.getParcelableExtra("clickedUser");
          otherUserId = otherUser.getUid();
          otherUserName = otherUser.getUsername();
      }
      if (intent.hasExtra("loggedUser")){
          loggedUser = intent.getParcelableExtra("loggedUser");
          loggedUserId = loggedUser.getUid();
      }
  </code></pre>
  
  <p>The error is problably this loggedUser and otherUser extra not being correctly managed. The weirdest thing is that using Back Button WORKS, while setting Up Button to work like Back Button doesn't</p>