samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/DetailsActivity.java
@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        getFragmentManager().enableDebugLogging(true);
        setContentView(R.layout.details_activity);
        if (savedInstanceState == null) {
            if (useLegacyFragment()) {
                DetailsFragment fragment = new DetailsFragment();
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
                getFragmentManager().beginTransaction()
                        .replace(R.id.details_fragment, fragment)
                        .commit();
            } else {
                NewDetailsFragment fragment = new NewDetailsFragment();
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
                fragment.setBackgroundVideo(hasBackgroundVideo());
                getFragmentManager().beginTransaction()
                        .replace(R.id.details_fragment, fragment)
                        .commit();
            }
        } else {
            if (useLegacyFragment()) {
                DetailsFragment fragment = (DetailsFragment) getFragmentManager()
                        .findFragmentById(R.id.details_fragment);
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
            } else {
                NewDetailsFragment fragment = (NewDetailsFragment) getFragmentManager()
                        .findFragmentById(R.id.details_fragment);
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
            }
        }
    }
/** Called when the activity is first created. */
Called when the activity is first created.
Called when the activity is first created .
@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        getFragmentManager().enableDebugLogging(true);
        setContentView(R.layout.details_activity);
        if (savedInstanceState == null) {
            if (useLegacyFragment()) {
                DetailsFragment fragment = new DetailsFragment();
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
                getFragmentManager().beginTransaction()
                        .replace(R.id.details_fragment, fragment)
                        .commit();
            } else {
                NewDetailsFragment fragment = new NewDetailsFragment();
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
                fragment.setBackgroundVideo(hasBackgroundVideo());
                getFragmentManager().beginTransaction()
                        .replace(R.id.details_fragment, fragment)
                        .commit();
            }
        } else {
            if (useLegacyFragment()) {
                DetailsFragment fragment = (DetailsFragment) getFragmentManager()
                        .findFragmentById(R.id.details_fragment);
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
            } else {
                NewDetailsFragment fragment = (NewDetailsFragment) getFragmentManager()
                        .findFragmentById(R.id.details_fragment);
                fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
            }
        }
    }
@ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; getFragmentManager ( ) . enableDebugLogging ( true ) ; setContentView ( R . layout . details_activity ) ; if ( savedInstanceState == null ) { if ( useLegacyFragment ( ) ) { DetailsFragment fragment = new DetailsFragment ( ) ; fragment . setItem ( ( PhotoItem ) getIntent ( ) . getParcelableExtra ( EXTRA_ITEM ) ) ; getFragmentManager ( ) . beginTransaction ( ) . replace ( R . id . details_fragment , fragment ) . commit ( ) ; } else { NewDetailsFragment fragment = new NewDetailsFragment ( ) ; fragment . setItem ( ( PhotoItem ) getIntent ( ) . getParcelableExtra ( EXTRA_ITEM ) ) ; fragment . setBackgroundVideo ( hasBackgroundVideo ( ) ) ; getFragmentManager ( ) . beginTransaction ( ) . replace ( R . id . details_fragment , fragment ) . commit ( ) ; } } else { if ( useLegacyFragment ( ) ) { DetailsFragment fragment = ( DetailsFragment ) getFragmentManager ( ) . findFragmentById ( R . id . details_fragment ) ; fragment . setItem ( ( PhotoItem ) getIntent ( ) . getParcelableExtra ( EXTRA_ITEM ) ) ; } else { NewDetailsFragment fragment = ( NewDetailsFragment ) getFragmentManager ( ) . findFragmentById ( R . id . details_fragment ) ; fragment . setItem ( ( PhotoItem ) getIntent ( ) . getParcelableExtra ( EXTRA_ITEM ) ) ; } } }
Called when the activity is first created.
Called when the activity is first created .