@Test public void testSmokeInitWithExtras() { launchIntent.putExtra(DirectoryChooserActivity.EXTRA_NEW_DIR_NAME, "my dir"); activity.onCreate(null); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); setContentView(R.layout.directory_chooser_activity); final String newDirName = getIntent().getStringExtra(EXTRA_NEW_DIR_NAME); final String initialDir = getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY); if (newDirName == null) { throw new IllegalArgumentException( "You must provide EXTRA_NEW_DIR_NAME when starting the DirectoryChooserActivity."); } if (savedInstanceState == null) { final FragmentManager fragmentManager = getFragmentManager(); final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(newDirName, initialDir); fragmentManager.beginTransaction() .add(R.id.main, fragment) .commit(); } }
DirectoryChooserActivity extends Activity implements
		DirectoryChooserFragment.OnFragmentInteractionListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); setContentView(R.layout.directory_chooser_activity); final String newDirName = getIntent().getStringExtra(EXTRA_NEW_DIR_NAME); final String initialDir = getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY); if (newDirName == null) { throw new IllegalArgumentException( "You must provide EXTRA_NEW_DIR_NAME when starting the DirectoryChooserActivity."); } if (savedInstanceState == null) { final FragmentManager fragmentManager = getFragmentManager(); final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(newDirName, initialDir); fragmentManager.beginTransaction() .add(R.id.main, fragment) .commit(); } } }
DirectoryChooserActivity extends Activity implements
		DirectoryChooserFragment.OnFragmentInteractionListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); setContentView(R.layout.directory_chooser_activity); final String newDirName = getIntent().getStringExtra(EXTRA_NEW_DIR_NAME); final String initialDir = getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY); if (newDirName == null) { throw new IllegalArgumentException( "You must provide EXTRA_NEW_DIR_NAME when starting the DirectoryChooserActivity."); } if (savedInstanceState == null) { final FragmentManager fragmentManager = getFragmentManager(); final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(newDirName, initialDir); fragmentManager.beginTransaction() .add(R.id.main, fragment) .commit(); } }  }
DirectoryChooserActivity extends Activity implements
		DirectoryChooserFragment.OnFragmentInteractionListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); setContentView(R.layout.directory_chooser_activity); final String newDirName = getIntent().getStringExtra(EXTRA_NEW_DIR_NAME); final String initialDir = getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY); if (newDirName == null) { throw new IllegalArgumentException( "You must provide EXTRA_NEW_DIR_NAME when starting the DirectoryChooserActivity."); } if (savedInstanceState == null) { final FragmentManager fragmentManager = getFragmentManager(); final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(newDirName, initialDir); fragmentManager.beginTransaction() .add(R.id.main, fragment) .commit(); } }  @Override void onCreate(Bundle savedInstanceState); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onSelectDirectory(@Nonnull String path); @Override void onCancelChooser(); }
DirectoryChooserActivity extends Activity implements
		DirectoryChooserFragment.OnFragmentInteractionListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); setContentView(R.layout.directory_chooser_activity); final String newDirName = getIntent().getStringExtra(EXTRA_NEW_DIR_NAME); final String initialDir = getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY); if (newDirName == null) { throw new IllegalArgumentException( "You must provide EXTRA_NEW_DIR_NAME when starting the DirectoryChooserActivity."); } if (savedInstanceState == null) { final FragmentManager fragmentManager = getFragmentManager(); final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(newDirName, initialDir); fragmentManager.beginTransaction() .add(R.id.main, fragment) .commit(); } }  @Override void onCreate(Bundle savedInstanceState); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onSelectDirectory(@Nonnull String path); @Override void onCancelChooser(); static final String EXTRA_NEW_DIR_NAME; static final String EXTRA_INITIAL_DIRECTORY; static final String RESULT_SELECTED_DIR; static final int RESULT_CODE_DIR_SELECTED; }