1

Like the title says. I have a dialogFragment I want to display in the click of a button. This works just fine. The problem is that when I put the phone to sleep with the fragment still showing, when I wake up the phone and reopen the app, there's several of the same fragment showing at the same time. It doesn't occur if I just leave the app and come back, only when I put the phone to sleep.

Here's the part of my code that handles the click and bringing up the fragment:

       settingsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!isSettingsOpen) {
                if(player.isPlaying()) {
                    player.pause();
                }
                SettingsDialogFragment settingsDialogFragment = SettingsDialogFragment.newInstance();
                settingsDialogFragment.show(getSupportFragmentManager(), "");
                getSupportFragmentManager().executePendingTransactions();
                isSettingsOpen = true;

                settingsDialogFragment.getDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        player.setPlaybackSpeed(SettingsManager.getPlaybackSpeedFloat(PlayerActivity.this));
                        stepCount = SettingsManager.getStepCountInt(PlayerActivity.this);
                        isSettingsOpen = false;

                    }
                });
            }

        }
    });

This is set up in the Activity's onCreate method.

Atti
  • 31
  • 2

0 Answers0