I have a button in a Bottom Sheet fragment and the app should exit the fragment.
I tried a couple different ways to do it, but none of the ways I tried worked.
I tried to use
getActivity.onBackPress()
, it worked, but it exit the entire app. I tried to press the back bottom manually, it goes to the main Activity. To exit the app, i need to press the back button twice, however, I only did onBackPress() once in my code, it still exit the app.I tried to use
getActivity().getFragmentManager().popBackStack();
, and I found out my backstack is empty (null) when I execute this and the code would not do anything.