Example usage for android.content Intent CATEGORY_OPENABLE

List of usage examples for android.content Intent CATEGORY_OPENABLE

Introduction

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

Prototype

String CATEGORY_OPENABLE

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

Click Source Link

Document

Used to indicate that an intent only wants URIs that can be opened with ContentResolver#openFileDescriptor(Uri,String) .

Usage

From source file:com.android.talkback.labeling.LabelManagerSummaryActivity.java

private void addImportCustomLabelClickListener() {
    final Button importLabel = (Button) findViewById(R.id.import_labels);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        importLabel.setVisibility(View.GONE);
        return;//from w w w. j  a  v a2 s . c  o m
    }
    importLabel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent importIntent = new Intent();
            importIntent.setAction(Intent.ACTION_GET_CONTENT);
            importIntent.setType("application/json");
            importIntent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(importIntent, SELECT_LABEL_FILE_REQUEST);
        }
    });
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public void launchDocumentImagePicker(final Fragment fragment) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.putExtra(Intent.EXTRA_MIME_TYPES, MessagePartData.ACCEPTABLE_IMAGE_TYPES);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(ContentType.IMAGE_UNSPECIFIED);

    fragment.startActivityForResult(intent, REQUEST_PICK_IMAGE_FROM_DOCUMENT_PICKER);
}

From source file:de.schildbach.wallet.ui.backup.BackupWalletDialogFragment.java

private void backupWallet() {
    passwordView.setEnabled(false);//from w w  w. j  av  a2 s .  c om
    passwordAgainView.setEnabled(false);

    final DateFormat dateFormat = Iso8601Format.newDateFormat();
    dateFormat.setTimeZone(TimeZone.getDefault());

    final StringBuilder filename = new StringBuilder(Constants.Files.EXTERNAL_WALLET_BACKUP);
    filename.append('-');
    filename.append(dateFormat.format(new Date()));

    final Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(Constants.MIMETYPE_WALLET_BACKUP);
    intent.putExtra(Intent.EXTRA_TITLE, filename.toString());
    startActivityForResult(intent, REQUEST_CODE_CREATE_DOCUMENT);
}

From source file:com.z299studio.pb.ActionDialog.java

private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    try {/*from   w  ww. ja v a 2  s.  c om*/
        getActivity().startActivityForResult(
                Intent.createChooser(intent, getResources().getString(R.string.select_file)),
                REQ_CODE_FILE_SELECTION);
    } catch (android.content.ActivityNotFoundException ex) {
        Application.showToast(getActivity(), R.string.no_file_explorer, Toast.LENGTH_SHORT);
    }
}

From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java

/**
 * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
 * on the Upload from App mini FAB for the linked action and {@link Toast} showing the underlying action.
 *//*  ww w. j ava2 s  .c  o m*/
private void registerFabUploadFromAppListeners() {
    getFabUploadFromApp().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent action = new Intent(Intent.ACTION_GET_CONTENT);
            action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
            //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
            }
            getActivity().startActivityForResult(
                    Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                    FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS);
            getFabMain().collapse();
            recordMiniFabClick();
        }
    });

    getFabUploadFromApp().setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getActivity(), R.string.actionbar_upload_from_apps, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}

From source file:com.farmerbb.notepad.fragment.NoteListFragment.java

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override/* ww w.  j av  a 2s. co m*/
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {
    case R.id.action_start_selection:
        listener.startMultiSelect();
        return true;
    case R.id.action_settings:
        Intent intentSettings = new Intent(getActivity(), SettingsActivity.class);
        startActivity(intentSettings);
        return true;
    case R.id.action_import:
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "text/plain", "text/html", "text/x-markdown" });
        intent.setType("*/*");

        try {
            getActivity().startActivityForResult(intent, MainActivity.IMPORT);
        } catch (ActivityNotFoundException e) {
            showToast(R.string.error_importing_notes);
        }
        return true;
    case R.id.action_about:
        DialogFragment aboutFragment = new AboutDialogFragment();
        aboutFragment.show(getFragmentManager(), "about");
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:de.treichels.hott.ui.android.MdlViewerActivity.java

/**
 * Fires an intent to spin up the "file chooser" UI and select a file. Response will be handled by {@link MdlViewerActivity.onActivityResult()}
 *///from  w  ww .j a  v a 2s .  co m
public void performFileSearch() {
    Toast.makeText(getApplicationContext(), R.string.msg_select_mdl, Toast.LENGTH_SHORT).show();

    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(MDL_MIME_TYPE);

    startActivityForResult(intent, READ_REQUEST_CODE);
}

From source file:com.core.base.js.UploadHandler.java

private Intent createDefaultOpenableIntent() {
    // Create and return a chooser with the default OPENABLE
    // actions including the camera, camcorder and sound
    // recorder where available.
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");

    Intent chooser = createChooserIntent();
    chooser.putExtra(Intent.EXTRA_INTENT, i);
    return chooser;
}

From source file:com.jefftharris.passwdsafe.StorageFileListFragment.java

/** Start the intent to open a file */
private void startOpenFile() {
    Intent intent = new Intent(DocumentsContractCompat.INTENT_ACTION_OPEN_DOCUMENT);

    // Filter to only show results that can be "opened", such as a
    // file (as opposed to a list of contacts or timezones)
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    intent.setType("application/*");

    startActivityForResult(intent, OPEN_RC);
}

From source file:com.MustacheMonitor.MustacheMonitor.StacheCam.java

/**
 * Get image from photo library./*from   w w  w.j  a  v  a  2 s . c o  m*/
 *
 * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
 * @param srcType           The album to get image from.
 * @param returnType        Set the type of image to return.
 */
// TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
public void getImage(int srcType, int returnType) {
    Intent intent = new Intent();
    String title = GET_PICTURE;
    if (this.mediaType == PICTURE) {
        intent.setType("image/*");
    } else if (this.mediaType == VIDEO) {
        intent.setType("video/*");
        title = GET_VIDEO;
    } else if (this.mediaType == ALLMEDIA) {
        // I wanted to make the type 'image/*, video/*' but this does not work on all versions
        // of android so I had to go with the wildcard search.
        intent.setType("*/*");
        title = GET_All;
    }

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (this.cordova != null) {
        this.cordova.startActivityForResult((Plugin) this, Intent.createChooser(intent, new String(title)),
                (srcType + 1) * 16 + returnType + 1);
    }
}