@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      mImageUriProvider = ShowcaseApplication.Companion.getImageUriProvider();
      mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());

      final View view =
          getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_uri_override, null);

      // setup edit text
      mEditText = view.findViewById(R.id.dialog_uri_override_edittext);
      final String previousUri = mImageUriProvider.getUriOverride();
      if (!TextUtils.isEmpty(previousUri)) {
        mEditText.setText(mImageUriProvider.getUriOverride());
      }

      // setup history text view
      final TextView historyTextView = view.findViewById(R.id.dialog_uri_override_history_textview);
      final String historyUri = mSharedPreferences.getString(KEY_URI_OVERRIDE_HISTORY, null);
      if (!TextUtils.isEmpty(historyUri)) {
        historyTextView.setText(
            getString(R.string.preference_uri_override_dialog_history, historyUri));
        historyTextView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                mEditText.setText(historyUri);
              }
            });
        historyTextView.setVisibility(View.VISIBLE);
      }

      final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder
          .setMessage(R.string.preference_uri_override_dialog_message)
          .setView(view)
          .setPositiveButton(R.string.preference_uri_override_dialog_button_set, this)
          .setNeutralButton(R.string.preference_uri_override_dialog_button_cancel, null)
          .setNegativeButton(R.string.preference_uri_override_dialog_button_remove, this);
      return builder.create();
    }
Dialog asking for a new URI override
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/settings/SettingsFragment.java