I have navigation box activity and lots of fragments that I get through the navigation box.
In some of these snippets, I show a dialog that says "Loading .." when background tasks are performed.
Now I have made my dialogs not canceled on dialog.setCancelable(false) so that the user does not accidentally reject it by clicking anywhere on the screen. This makes it impossible to cancel even when the back button is pressed.
This is the code for my dialogue -
Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.custom_progress_dialog); ((TextView)dialog.findViewById(R.id.custom_dialog_message)).setText("Loading ..."); dialog.setCancelable(false); dialog.show();
I need to write code to close the download dialog and go to the previous fragment when the "Back back" button on any fragment is clicked.
Can someone help me? Basically I need to implement fragment specific backPress. Thanks!
source share