title: My Android App Does Not Exit When Pressing Back Button
body: <p>I am new to Android programming and I wrote an app implementing only the <code>Activity.OnCreate</code> method. I expected to go back to the previous view (which has to be the home screen due to the basic intent-filter I have) by pressing the BACK button but it does not. I managed to do that only by pressing the HOME button. (I have tested my app on multiple devices and it behaves the same.) Has everybody else went into the same problem? What is the solution? (the git repo of my app is here: <a href="https://github.com/falcondai/android_lab1" rel="nofollow">https://github.com/falcondai/android_lab1</a>)</p>
  
  <p>The following is the Activity I failed to back out properly (the BACK key works fine for all other activities):</p>
  
  <pre><code>public class NameGetterActivity extends Activity 
  {
      private static final String TAG = "NameGetterActivity";
  
      private EditText name_fld;
      private Button submit_btn;
      private Button test_btn;
  
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          this.setContentView(R.layout.name_getter);
  
          name_fld = (EditText)this.findViewById(R.id.editText1);
          submit_btn = (Button)this.findViewById(R.id.button1);
          test_btn = (Button)this.findViewById(R.id.button2);
  
          submit_btn.setOnClickListener(
                  new OnClickListener() {
                      public void onClick(View v) {
                          Log.d(TAG, name_fld.getText().toString());
  
                          Intent i = new Intent(NameGetterActivity.this, HelloWorldActivity.class);
                          i.putExtra("name", name_fld.getText().toString());
                          startActivity(i);
                      }
                  }
              );
  
          test_btn.setOnClickListener(
                  new OnClickListener() {
                      public void onClick(View v) {
                          Log.d(TAG, "sensor activity button pressed");
  
                          Intent i = new Intent(NameGetterActivity.this, SensorActivity.class);
                          startActivity(i);
                      }
                  }
              );
      }
  
  }
  </code></pre>