Something like that:
Activity activity = getActivity(); int orientation = activity.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { // Start DialogFragment as dialog MyFragmentDialog frag = new MyFragmentDialog(); frag.show(getFragmentManager(), "dialog"); } else { // Start activity that embeds DialogFragment Intent intent = new SimpleFragmentActivity.IntentBuilder(activity, MyFragmentDialog.class) .create(); activity.startActivity(intent); }
SimpleFragmentActivity
is a wrapper operation I wrote that is just convenient for inserting a fragment dialog in an exercise, but basically you just need an activity that includes MyFragmentDialog. Here's the source of shell activity: https://github.com/jt-gilkeson/fragment-utils
source share