title: How to disable Back button on second Bottom Sheet Dialog?
body: <p>I am creating a MainActivity. This activity has a button to open a Fragment and the Fragment has a button to open a bottom sheet dialog. </p>
  
  <p>When I am on the Fragment, I can press Back button to return to MainActivity. However, when I have already opened the Bottom Dialog, I want to disable the Back button so that user can not press Back button when the Bottom Dialog is showing. So how can I do this? Thank you. </p>
  
  <p>MainActivity</p>
  
  <pre><code>public class MainActivity extends SdwBaseActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  public void startAction(View view){
      LoadCashTutorialScreen loadCashTutorialScreen = LoadCashTutorialScreen.newInstance();
   getSupportFragmentManager().beginTransaction().replace(R.id.container, loadCashTutorialScreen, "LoadCashTutorialScreen").addToBackStack("LoadCashTutorialScreen").commit();
  }
  
  @Override
  public void onBackPressed(){
        super.onBackPressed()
        //do something so that the back button is disable when the Bottom Dialog is showing
  }
  }
  </code></pre>
  
  <p>Fragment:</p>
  
  <pre><code>public class LoadCashTutorialScreen extends Fragment{
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View view = initView(inflater, container, R.layout.load_cash_tutorial_screen);
          Button startDialog = view.findViewById(R.id.dialogButton);
          startDialog.setOnClickListener(view1 -&gt; {
              MyBottomDialog dialog = new MyBottomDialog();
              dialog.show(activity.getSupportFragmentManager(), "BottomDialog");
          });
  
          return view;
      }
  }
  </code></pre>
  
  <p>Dialog:</p>
  
  <pre><code>public class MyBottomDialog extends BottomSheetDialogFragment {
      @Override
      public void setupDialog(@NonNull Dialog dialog, int style) {
          super.setupDialog(dialog, style);
          View contentView = View.inflate(getContext(), R.layout.load_cash_bottom_dialog, null);
          dialog.setContentView(contentView);
          dialog.setCanceledOnTouchOutside(false);
          dialog.setCancelable(false);
      }
  }
  </code></pre>
  
  <p>Note: I used to write some methods on onBackPressed() to prevent dialog disappears, however, the dialog always disappear when pressing Back. After debugging, I realize that onBackPressed() is not reached when the bottom dialog is showing. I do not know why.  </p>