title: Can I check which the previous activity was, Android?
body: <p>I can reach activity C from two different activities, A and B. Activity C has one button. I would like to check if I went to C from A or to C from B. If I went from A to C, I would like the button to do one thing and if I went from B to C, I would like the button to do another thing. </p>
  
  <p>Is it possible to check which the previous activity was?</p>
  
  <p>Something like this...</p>
  
  <pre><code>else if (id == R.id.action_button) {
  
  if (previosActivity == A) {
  
      Intent intent = new Intent(this, NewActivity.class);
      startActivity(intent);  
  }
  
  else if (previosActivity == B) {
  
      Intent intent = new Intent(this, AnotherActivity.class);
      startActivity(intent);
  }
  
  return true;
  }
  </code></pre>