Disable back button in android


Question

How to disable back button in android while logging out the application?

1
312
4/3/2017 3:25:50 PM

Override the onBackPressed method and do nothing if you meant to handle the back button on the device.

@Override
public void onBackPressed() {
   if (!shouldAllowBack()) {
       doSomething();
   } else {
       super.onBackPressed();
   }
}
632
12/13/2017 6:55:16 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon