I am working with an app in AndroidStudio. What code could I implement so that when the back is called to exit the app, it tells me if I want to exit it or not?
I am working with an app in AndroidStudio. What code could I implement so that when the back is called to exit the app, it tells me if I want to exit it or not?
Basically you have to override the method
onBackPressed
of theActivity
:You can reset the variable
backpress
so that it asks for "press again" after X time by adding the following code inside the methodonBackPressed
: