Exit android app on back pressed

后端 未结 12 1949
逝去的感伤
逝去的感伤 2021-01-30 10:57

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.

12条回答
  •  梦谈多话
    2021-01-30 11:52

    Just use the code finish(); under your intent to close the activity. So, It will not appear again. This solved mine.

    startActivity(new Intent(SplashActivity.this, MainActivity.class));
    finish();
    

提交回复
热议问题