user3218332 user3218332 - 29 days ago 14
Android Question

Exit android app on back pressed

I am building an Android App. How to exit an Android App when back is pressed. Android version is 2.3.3 and above. The Android App goes to previous activity which i don't want.

Answer

Yes, you can exit an Android App on back pressed. Just override the onBackPressed() method.

public void onBackPressed() {
  finish();
}