title: How to set onBackPressed in Second Activity
body: <p>I set the <code>&lt;button&gt;</code> in <code>activity_main.xml</code></p>
  
  <pre><code>&lt;Button
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:onClick="ReturnHome"
      android:text="Go Back"
      android:layout_marginBottom="79dp"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:layout_alignParentEnd="true" /&gt;
  </code></pre>
  
  <p>And now I'd like to add <code>onBackPressed</code> method in <code>AnswerActivity</code></p>
  
  <pre><code>public class AnswerActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_answer);
      TextView textViewDisplayResult = (TextView) findViewById(R.id.text_view_display_result);
  </code></pre>
  
  <p>To be able to go back to previous page which is <code>Fragment</code>.</p>
  
  <p>Can somebody guide me step by step how to do it?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I wrote something like this</p>
  
  <pre><code>     super.onBackPressed();
          Intent returnIntent = new Intent();
          finish();
  </code></pre>
  
  <p>But it says 'variable "returnIntent" is never used'. How to fix it?</p>