Example usage for android.content Intent ACTION_GET_CONTENT

List of usage examples for android.content Intent ACTION_GET_CONTENT

Introduction

In this page you can find the example usage for android.content Intent ACTION_GET_CONTENT.

Prototype

String ACTION_GET_CONTENT

To view the source code for android.content Intent ACTION_GET_CONTENT.

Click Source Link

Document

Activity Action: Allow the user to select a particular kind of data and return it.

Usage

From source file:babybear.akbquiz.ConfigActivity.java

/**
 * //from   ww w  . j a va2 s  .  c  om
 */
protected void customBgImage() {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int width = dm.widthPixels;
    int height = dm.heightPixels;

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
    intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*"); // 
    intent.putExtra("crop", "circle"); // ?
    intent.putExtra("aspectX", width); // ? 
    intent.putExtra("aspectY", height); // ? .
    intent.putExtra("output", Uri.fromFile(customBgImage));// 
    intent.putExtra("outputFormat", "PNG");// ?
    intent.putExtra("noFaceDetection", true); // ?
    intent.putExtra("return-data", false); // ??Intent
    startActivityForResult(intent, REQUESTCODE_IMAGE);
}

From source file:com.ratebeer.android.gui.fragments.BeerViewFragment.java

public void onStartPhotoPicking() {
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.setType("image/*");
    startActivityForResult(i, ACTIVITY_PICKPHOTO);
}

From source file:com.filemanager.free.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *//*from   ww  w .jav a2s.c  om*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    context = this;
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception ignored) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
    }
    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,
                R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.addDrawerListener(mDrawerToggle);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
        mDrawerToggle.syncState();
    }

    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(con, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }

    //search
    searchView();
    //admob
    mInterstitialAd = new InterstitialAd(this);
    // set the ad unit ID
    mInterstitialAd.setAdUnitId("ca-app-pub-2257698129050878/4313141545");
    requestNewInterstitial();
}

From source file:com.nextgis.mobile.activity.MainActivity.java

public void addLocalLayer() {
    // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
    // browser.//  ww w .ja v a2s  . c o m
    // https://developer.android.com/guide/topics/providers/document-provider.html#client
    Intent intent;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
    } else {
        intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    }
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        startActivityForResult(Intent.createChooser(intent, getString(R.string.select_file)), FILE_SELECT_CODE);
    } catch (android.content.ActivityNotFoundException ex) {
        //TODO: open select local resource dialog
        // Potentially direct the user to the Market with a Dialog
        Toast.makeText(this, getString(R.string.warning_install_file_manager), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.krayzk9s.imgurholo.activities.MainActivity.java

private void displayUpload() {
    new AlertDialog.Builder(this).setTitle(R.string.dialog_upload_options_title)
            .setItems(R.array.upload_options, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    Intent intent;/*w  ww. j ava  2s  .  c  om*/
                    MainActivity activity = MainActivity.this;
                    switch (whichButton) {
                    case 0:
                        final EditText urlText = new EditText(activity);
                        urlText.setSingleLine();
                        new AlertDialog.Builder(activity).setTitle(R.string.dialog_url_title).setView(urlText)
                                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {
                                        if (urlText.getText() != null) {
                                            UrlAsync urlAsync = new UrlAsync(urlText.getText().toString(),
                                                    apiCall);
                                            urlAsync.execute();
                                        }
                                    }
                                }).setNegativeButton(R.string.dialog_answer_cancel,
                                        new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                // Do nothing.
                                            }
                                        })
                                .show();
                        break;
                    case 1:
                        intent = new Intent();
                        intent.setType("image/*");
                        intent.setAction(Intent.ACTION_GET_CONTENT);
                        intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                        startActivityForResult(Intent.createChooser(intent, "Select Picture"), 3);
                        break;
                    case 2:
                        intent = new Intent("android.media.action.IMAGE_CAPTURE");
                        startActivityForResult(intent, 4);
                        break;
                    case 3:
                        new AlertDialog.Builder(activity).setTitle(R.string.dialog_explanation_title)
                                .setMessage(R.string.dialog_explanation_summary)
                                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int whichButton) {
                                        //do nothing
                                    }
                                }).show();
                    default:
                        break;
                    }
                }
            }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing.
                }
            }).show();
}

From source file:com.fatelon.partyphotobooth.setup.fragments.EventInfoSetupFragment.java

/**
 * Starts the {@link Activity} for event logo selection.
 *
 * @param context the {@link Context}./*from www .  j  ava2s . co m*/
 */
private void launchLogoSelection(Context context) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(EVENT_LOGO_MIME_TYPE);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);

    Intent chooserIntent = Intent.createChooser(intent,
            context.getString(R.string.event_info_setup__event_logo_chooser_title));
    startActivityForResult(chooserIntent, EVENT_LOGO_REQUEST_CODE);
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *///from  www .  ja  v a2  s.c o  m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();
    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {

        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception e) {

    }
    updateDrawer();

    // setting window background color instead of each item, in order to reduce pixel overdraw
    if (theme1 == 0) {
        /*if(Main.IS_LIST) {
                
        getWindow().setBackgroundDrawableResource(android.R.color.white);
        } else {
                
        getWindow().setBackgroundDrawableResource(R.color.grid_background_light);
        }*/
        getWindow().setBackgroundDrawableResource(android.R.color.white);
    } else {
        getWindow().setBackgroundDrawableResource(R.color.holo_dark_background);
    }

    if (savedInstanceState == null) {

        if (openprocesses) {
            android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager()
                    .beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
        //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
    }

    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer_l, /* nav drawer image to replace 'Up' caret */
                R.string.drawer_open, /* "open drawer" description for accessibility */
                R.string.drawer_close /* "close drawer" description for accessibility */
        ) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mDrawerToggle.syncState();
    } /*((ImageButton) findViewById(R.id.drawer_buttton)).setOnClickListener(new ImageView.OnClickListener() {
      @Override
      public void onClick(View view) {
          if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
              mDrawerLayout.closeDrawer(mDrawerLinear);
          } else mDrawerLayout.openDrawer(mDrawerLinear);
      }
      });*/
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor((currentTab == 1 ? skinTwo : skin)));
        ((Activity) this).setTaskDescription(taskDescription);
    }
}

From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountCar.java

/**
 * Displaying the car information in the layout.
 * @param res/*  w  w  w  .j a v a  2 s.co  m*/
 */
public void showMain(CarResponse res, PreferenceResponse prefResInit) {
    // Initializing the views
    setContentView(R.layout.my_account_car);
    this.imageView = (ImageView) this.findViewById(R.id.cameraView);
    carName = (EditText) this.findViewById(R.id.carName);
    bar = (RatingBar) this.findViewById(R.id.ratingBar1);
    seatsText = (EditText) this.findViewById(R.id.myAccountCarSeats);

    // Setting the number of seats available
    prefRes = prefResInit;
    seatsAvailable = prefRes.getPreferences().getSeatsAvailable();
    if (seatsAvailable > 0) {
        seatsText.setText(seatsAvailable.toString());
    } else {
        seatsText.setText("");
    }

    // If the user does have a car registered
    if (user.getCarId() != 0) {
        // Setting the car name
        carNameString = res.getCar().getCarName();
        // Setting the car ID
        id = res.getCar().getCarId();
        // Setting the comfort
        comfort = (float) res.getCar().getComfort();
        // Getting the car image
        byteArray = res.getCar().getPhoto();

        /*Values of the car from database*/

        // Display these values to the user
        carName.setText(carNameString);
        bar.setRating(comfort);

        String empty = "No car type set";
        byteArrayx = empty.getBytes();
        // If a new image is set, display it
        if (byteArray.length > 15) {
            if (!(res.getCar().getPhotoAsBase64().equals(Base64.encode(byteArrayx, Base64.URL_SAFE)))) {
                btm = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
                imageView.setImageBitmap(btm);
            }
        }
        // Indicates that the car is initialized
        isCarInitialized = true;
    }
    //if user does not yet have a car registated
    else {
        carNameString = "";
        id = -1;
        comfort = 0.0f;
        String empty = "No car type set";
        byteArray = empty.getBytes();
    }

    // Setting the button for taking a car picture
    Button photoButton = (Button) this.findViewById(R.id.cameraButton);
    photoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            carChanged = true;
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, "tempName");
            cameraIntent.putExtra("return-data", true);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);
        }
    });
    // Setting the button for getting a car picture from the phone
    Button getimageButton = (Button) this.findViewById(R.id.getimageButton);
    getimageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            carChanged = true;
            Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, ALBUM_REQUEST);
        }
    });
}

From source file:com.amaze.filemanager.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *///from   ww w .jav a  2  s . c  o  m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Sp = PreferenceManager.getDefaultSharedPreferences(this);
    initialisePreferences();
    setTheme();
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    DataUtils.clear();
    DataUtils.registerOnDataChangedListener(this);
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();
    //requesting storage permissions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        if (!checkStoragePermission())
            requestStoragePermission();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    if (mAsyncHelperFragment != null) {

        FragmentManager fm = getSupportFragmentManager();
        mAsyncHelperFragment = (AsyncHelper) fm.findFragmentByTag(TAG_ASYNC_HELPER);
    }

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {

        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            crossfadeInverse();
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception e) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager()
                    .beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
        //mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
    }

    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
                mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer_l, /* nav drawer image to replace 'Up' caret */
                R.string.drawer_open, /* "open drawer" description for accessibility */
                R.string.drawer_close /* "close drawer" description for accessibility */
        ) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        mDrawerToggle.syncState();
    } /*((ImageButton) findViewById(R.id.drawer_buttton)).setOnClickListener(new ImageView.OnClickListener() {
      @Override
      public void onClick(View view) {
          if (mDrawerLayout.isDrawerOpen(mDrawerLinear)) {
              mDrawerLayout.closeDrawer(mDrawerLinear);
          } else mDrawerLayout.openDrawer(mDrawerLinear);
      }
      });*/
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java

private void showVideoFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("video/*");

    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {/*  w  w w .  ja  v a  2 s  .c  om*/
        startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), VIDEO_REQUEST);
    } catch (android.content.ActivityNotFoundException ex) {
        // Potentially direct the user to the Market with a Dialog
        Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show();
    }
}