code: @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_host_image_gallery);
          ButterKnife.bind(this);
  
          Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
          if (fragment == null) {
              fragment = ImageGalleryFragment.newInstance(getIntent().getExtras());
              getSupportFragmentManager()
                      .beginTransaction()
                      .replace(android.R.id.content, fragment, "")
                      .commit();
          } else {
              getSupportFragmentManager()
                      .beginTransaction()
                      .attach(fragment)
                      .commit();
          }
      }
docs: region Lifecycle Methods