@Override
    public void onCreate(Bundle savedInstanceState) {
		// Call superclass creator.
        super.onCreate(savedInstanceState);
        
		// Set layout.
        this.setContentView(R.layout.dialog_file_chooser);
		
		// Set the background color.
        LinearLayout layout = (LinearLayout) this.findViewById(R.id.rootLayout);
        layout.setBackgroundColor(getResources().getColor(R.color.daidalos_backgroud));

		// Initialize fields.
		this.useBackButton = false;
		
        // Create the core of the file chooser.
        this.core = new FileChooserCore(this);
        
        // Verify if the optional parameters has been defined.
        String folderPath = null;
        Bundle extras = this.getIntent().getExtras();
        if(extras != null) {
    		if(extras.containsKey(INPUT_START_FOLDER)) folderPath = extras.getString(INPUT_START_FOLDER);
            if(extras.containsKey(INPUT_REGEX_FILTER)) core.setFilter(extras.getString(INPUT_REGEX_FILTER));
            if(extras.containsKey(INPUT_SHOW_ONLY_SELECTABLE)) core.setShowOnlySelectable(extras.getBoolean(INPUT_SHOW_ONLY_SELECTABLE));
            if(extras.containsKey(INPUT_FOLDER_MODE)) core.setFolderMode(extras.getBoolean(INPUT_FOLDER_MODE));
            if(extras.containsKey(INPUT_CAN_CREATE_FILES)) core.setCanCreateFiles(extras.getBoolean(INPUT_CAN_CREATE_FILES));
            if(extras.containsKey(INPUT_LABELS)) core.setLabels((FileChooserLabels) extras.get(INPUT_LABELS));
            if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_CREATE)) core.setShowConfirmationOnCreate(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_CREATE));
            if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_SELECT)) core.setShowConfirmationOnSelect(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_SELECT));
            if(extras.containsKey(INPUT_SHOW_FULL_PATH_IN_TITLE)) core.setShowFullPathInTitle(extras.getBoolean(INPUT_SHOW_FULL_PATH_IN_TITLE));
            if(extras.containsKey(INPUT_USE_BACK_BUTTON_TO_NAVIGATE)) this.useBackButton = extras.getBoolean(INPUT_USE_BACK_BUTTON_TO_NAVIGATE);
        }

        // Load the files of a folder.
        core.loadFolder(folderPath);
        this.startFolder = this.core.getCurrentFolder();
        
        // Add a listener for when a file is selected.
        core.addListener(new FileChooserCore.OnFileSelectedListener() {
			public void onFileSelected(File folder, String name) {
				// Pass the data through an intent.
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putSerializable(OUTPUT_FILE_OBJECT, folder);
				bundle.putString(OUTPUT_NEW_FILE_NAME, name);
				intent.putExtras(bundle);
				
                setResult(RESULT_OK, intent);
                finish();				
			}
			public void onFileSelected(File file) {
				// Pass the data through an intent.
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putSerializable(OUTPUT_FILE_OBJECT, file);
				intent.putExtras(bundle);
				
                setResult(RESULT_OK, intent);
                finish();	
			}
		});
    }
@ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; this . setContentView ( R . layout . dialog_file_chooser ) ; LinearLayout layout = ( LinearLayout ) this . findViewById ( R . id . rootLayout ) ; layout . setBackgroundColor ( getResources ( ) . getColor ( R . color . daidalos_backgroud ) ) ; this . useBackButton = false ; this . core = new FileChooserCore ( this ) ; String folderPath = null ; Bundle extras = this . getIntent ( ) . getExtras ( ) ; if ( extras != null ) { if ( extras . containsKey ( INPUT_START_FOLDER ) ) folderPath = extras . getString ( INPUT_START_FOLDER ) ; if ( extras . containsKey ( INPUT_REGEX_FILTER ) ) core . setFilter ( extras . getString ( INPUT_REGEX_FILTER ) ) ; if ( extras . containsKey ( INPUT_SHOW_ONLY_SELECTABLE ) ) core . setShowOnlySelectable ( extras . getBoolean ( INPUT_SHOW_ONLY_SELECTABLE ) ) ; if ( extras . containsKey ( INPUT_FOLDER_MODE ) ) core . setFolderMode ( extras . getBoolean ( INPUT_FOLDER_MODE ) ) ; if ( extras . containsKey ( INPUT_CAN_CREATE_FILES ) ) core . setCanCreateFiles ( extras . getBoolean ( INPUT_CAN_CREATE_FILES ) ) ; if ( extras . containsKey ( INPUT_LABELS ) ) core . setLabels ( ( FileChooserLabels ) extras . get ( INPUT_LABELS ) ) ; if ( extras . containsKey ( INPUT_SHOW_CONFIRMATION_ON_CREATE ) ) core . setShowConfirmationOnCreate ( extras . getBoolean ( INPUT_SHOW_CONFIRMATION_ON_CREATE ) ) ; if ( extras . containsKey ( INPUT_SHOW_CONFIRMATION_ON_SELECT ) ) core . setShowConfirmationOnSelect ( extras . getBoolean ( INPUT_SHOW_CONFIRMATION_ON_SELECT ) ) ; if ( extras . containsKey ( INPUT_SHOW_FULL_PATH_IN_TITLE ) ) core . setShowFullPathInTitle ( extras . getBoolean ( INPUT_SHOW_FULL_PATH_IN_TITLE ) ) ; if ( extras . containsKey ( INPUT_USE_BACK_BUTTON_TO_NAVIGATE ) ) this . useBackButton = extras . getBoolean ( INPUT_USE_BACK_BUTTON_TO_NAVIGATE ) ; } core . loadFolder ( folderPath ) ; this . startFolder = this . core . getCurrentFolder ( ) ; core . addListener ( new FileChooserCore . OnFileSelectedListener ( ) { public void onFileSelected ( File folder , String name ) { Intent intent = new Intent ( ) ; Bundle bundle = new Bundle ( ) ; bundle . putSerializable ( OUTPUT_FILE_OBJECT , folder ) ; bundle . putString ( OUTPUT_NEW_FILE_NAME , name ) ; intent . putExtras ( bundle ) ; setResult ( RESULT_OK , intent ) ; finish ( ) ; } public void onFileSelected ( File file ) { Intent intent = new Intent ( ) ; Bundle bundle = new Bundle ( ) ; bundle . putSerializable ( OUTPUT_FILE_OBJECT , file ) ; intent . putExtras ( bundle ) ; setResult ( RESULT_OK , intent ) ; finish ( ) ; } } ) ; }
Called when the activity is first created.