What I am trying to achieve is to have a fragment that on tablet it shows as a DialogFragment, while on smartphone it would be shown as a regular fragment. I am
To make a DialogFragment show as a regular Fragment, call add() or replace() using a resource ID for the fragment container, e.g
beginTransaction().add(R.id.fragment_container, fragment)
But to make the DialogFragment display as a dialog, call add(fragment, "Fragment Tag"). Behind the scenes this results in a call to add(resId, fragment), setting the resource ID for the fragment container to 0, which causes the DialogFragment to set its showAsDialog option to true.
As a consequence you can use a dialog fragment as a dialog or a regular fragment - depending on your needs - without needing to create any special logic to do it.