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:org.odk.collect.android.widgets.ArbitraryFileWidget.java

private void performFileSearch() {
    Intent intent = new Intent(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT
            ? Intent.ACTION_OPEN_DOCUMENT
            : Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*"); // all file types
    ((FormEntryActivity) getContext()).startActivityForResult(intent,
            ApplicationConstants.RequestCodes.ARBITRARY_FILE_CHOOSER);
}

From source file:com.uphyca.kitkat.storage.ui.MainFragment.java

/**
 * ?/*from   w w  w.  j a  v a 2  s.c  o m*/
 */
@OnClick(R.id.button_delete)
void onDeleteButtonClick() {
    Intent intent = new Intent().setAction(Intent.ACTION_OPEN_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE)
            .setType("text/plain");
    startActivityForResult(intent, REQUEST_DELETE);
}

From source file:com.yandex.disk.rest.example.ListExampleFragment.java

private void openAddFileDialog() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(/*from  w w  w. ja  v  a  2  s. c  o m*/
            Intent.createChooser(intent, getText(R.string.example_loading_get_file_to_upload_chooser_title)),
            GET_FILE_TO_UPLOAD);
}

From source file:java_lang_programming.com.android_media_demo.ImageSelectionCropDemo.java

/**
 * start ExternalApp if the required READ_EXTERNAL_STORAGE permission has been granted.
 *///from   ww  w .  j a  v a  2 s .co  m
private void startExternalAppSelectableImage() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

    // 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("image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        intent.putExtra(Intent.EXTRA_MIME_TYPES, types.toArray());
    }
    startActivityForResult(Intent.createChooser(intent, null), ImageSelectionCropDemo.REQUEST_CODE_CHOOSER);
}

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

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override//from  w w w  . j a v  a 2 s. c  o  m
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {
    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, 42);
        } 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:com.activiti.android.platform.provider.transfer.ContentTransferManager.java

public static final void requestGetContentFromProvider(Fragment fr) {
    String tmpMimetype = "*/*";
    if (AndroidVersion.isKitKatOrAbove()) {
        isMediaProviderSupported(fr.getActivity());

        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType(tmpMimetype);//w  w  w  .  j  av  a  2 s  . c  o m
        fr.startActivityForResult(intent, PICKER_REQUEST_CODE);
    }
}

From source file:info.guardianproject.gpg.FileDialogFragment.java

/**
 * Opens the preferred installed file manager on Android and shows a toast
 * if no manager is installed.// w  w  w  . j  a  v  a2s. c o  m
 * 
 * @param activity
 * @param filename default selected file, not supported by all file managers
 * @param type can be text/plain for example
 * @param requestCode requestCode used to identify the result coming back
 *            from file manager to onActivityResult() in your activity
 */
public static void openFile(Activity activity, String filename, String type, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    intent.setData(Uri.parse("file://" + filename));
    intent.setType(type);

    try {
        activity.startActivityForResult(intent, requestCode);
    } catch (ActivityNotFoundException e) {
        // No compatible file manager was found.
        Toast.makeText(activity, R.string.error_no_file_manager_installed, Toast.LENGTH_SHORT).show();
    }
}

From source file:mobisocial.bento.anyshare.ui.FeedItemListActivity.java

private void goSelection() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_PICK);
}

From source file:httbdd.cse.nghiatran.halofind.screen.MainActivity.java

private void pickFromGallery() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(Intent.createChooser(intent, getString(R.string.label_select_picture)),
            REQUEST_SELECT_PICTURE);//w  ww. j ava  2 s  . c o m
}