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.
Kotlin:
override fun onBackPressed() { val exitIntent = Intent(Intent.ACTION_MAIN) exitIntent.addCategory(Intent.CATEGORY_HOME) exitIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP startActivity(exitIntent) }
Other codes have problems, some does not work and some needs API classification.