Disable back button in android

后端 未结 17 1372
名媛妹妹
名媛妹妹 2020-11-22 05:10

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

相关标签:
17条回答
  • 2020-11-22 06:03

    Just using this code: If you want backpressed disable, you dont use super.OnBackPressed();

    @Override
    public void onBackPressed() {
    
    }
    
    0 讨论(0)
  • 2020-11-22 06:04

    You can override the onBackPressed() method in your activity and remove the call to super class.

    @Override
    public void onBackPressed() {
      //remove call to the super class
      //super.onBackPressed();
    }
    
    0 讨论(0)
  • 2020-11-22 06:05

    You just need to override the method for back button. You can leave the method empty if you want so that nothing will happen when you press back button. Please have a look at the code below:

    @Override
    public void onBackPressed() 
    {
       // Your Code Here. Leave empty if you want nothing to happen on back press.
    }
    
    0 讨论(0)
  • 2020-11-22 06:06

    Simply override the onBackPressed() method.

    @Override
    public void onBackPressed() { }
    
    0 讨论(0)
  • 2020-11-22 06:09

    For me just overriding onBackPressed() did not work but explicit pointing which activity it should start worked well:

    @Override
    public void onBackPressed(){
      Intent intent = new Intent(this, ActivityYouWanToGoBack.class);
      startActivity(intent);
    }
    
    0 讨论(0)
提交回复
热议问题