Reputation: 10472
In my app sometimes the user clicks on the back button, and there is no response, so they click again right away, and instead of going back to previous screen they go 2-3 screens back. Sometimes out of the app entirely. And yet these back clicks all occured while just one screen was shown! Is there any way to intercept this and ignore these follow up back clicks. Perhaps observe their spacing or the screen in which they occured? Does anyone else have this problem?
My guess is nothing can be done because the user has ultimate control over back button, but why does Android not ignore the extra clicks since they all happen on the same page and it has not even stated to switch??
Upvotes: 0
Views: 2625
Reputation: 356
You can catch the back button easily with the below code, however you should really not be taking forever to respond. Your UI thread is blocked doing something and this is fundamentally wrong.
@Override
public void onBackPressed() {
// do something on back.
return;
}
Upvotes: 8