title: How to close Android activity and return to previous/main activity?
body: <p>I'm trying to understand tutorials with using intents to open up a java.class activity. I can manage to open up the activity using this code:</p>
  
  <pre><code>    Intent in = new Intent(MainActivity.this, settingmenu.class);
  
      startActivity(in);
      setResult(Activity.RESULT_OK);
      finish();
  </code></pre>
  
  <p>In that activity, I plan to have edittexts to be used in the settings, but first I want to understand how to simply RETURN to the previous activity. My onClick method for my buttons plays a method that is this:</p>
  
  <pre><code>public void cancel()
  {
      this.finish();
      return;
  }
  </code></pre>
  
  <p>However, when pressing the button, the app crashes. What am I doing differently? Several tutorials say use finish(), but I feel off.</p>