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.shengtao.chat.chatUI.activity.ChatActivity.java

/**
 * //from  w w  w. j  a va 2s  .co  m
 */
private void selectFileFromLocal() {
    Intent intent = null;
    //      if (Build.VERSION.SDK_INT < 19) {
    intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    //      } else {
    //         intent = new Intent(Intent.ACTION_PICK,
    //                 android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    //      }
    startActivityForResult(intent, REQUEST_CODE_SELECT_FILE);
}

From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private boolean openDocument() {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    final String[] mimeTypes = { "image/png", "image/jpeg", "image/gif" };
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    try {/*from w  ww  . java2  s.  c om*/
        startActivityForResult(intent, REQUEST_OPEN_DOCUMENT);
    } catch (final ActivityNotFoundException e) {
        return false;
    }
    return true;
}

From source file:org.kontalk.ui.AbstractComposeFragment.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private Intent createGalleryIntent(boolean useSAF) {
    Intent intent;//  ww  w .  j a va  2s  .  co  m
    if (!useSAF) {
        intent = SystemUtils.externalIntent(Intent.ACTION_GET_CONTENT)
                .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        intent = SystemUtils.externalIntent(Intent.ACTION_OPEN_DOCUMENT);
    }

    return intent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*")
            .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}

From source file:com.teeptrak.controller.MainActivity.java

private void openFileChooser(int aFileType) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(aFileType == FILE_TYPE_ZIP ? DfuService.MIME_TYPE_ZIP : MIME_TYPE_TEXT);
    //intent.setType(DfuService.MIME_TYPE_ZIP);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    if (intent.resolveActivity(getPackageManager()) != null) {
        // file browser has been found on the device
        startActivityForResult(intent, REQUEST_SELECT_FILE);
    }//from www  .  java  2s  .  co m
    //else
    //{
    // there is no any file browser app, let's try to download one
    //  final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
    //  final ListView appsList = (ListView) customView.findViewById(android.R.id.list);
    //  appsList.setAdapter(new FileBrowserAppsAdapter(this));
    //  appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    //  appsList.setItemChecked(0, true);
    //  new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView)
    //          .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
    //            @Override
    //            public void onClick(final DialogInterface dialog, final int which) {
    //              dialog.dismiss();
    //            }
    //          }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
    //    @Override
    //    public void onClick(final DialogInterface dialog, final int which) {
    //      final int pos = appsList.getCheckedItemPosition();
    //      if (pos >= 0) {
    //        final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
    //        final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
    //        startActivity(storeIntent);
    //      }
    //    }
    //  }).show();
    //}
}

From source file:eu.faircode.adblocker.ActivitySettings.java

private Intent getIntentCreateExport() {
    Intent intent;/*from ww w.  ja  va 2s.  c  o  m*/
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        if (Util.isPackageInstalled("org.openintents.filemanager", this)) {
            intent = new Intent("org.openintents.action.PICK_DIRECTORY");
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(
                    Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager"));
        }
    } else {
        intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("*/*"); // text/xml
        intent.putExtra(Intent.EXTRA_TITLE,
                "adblocker_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml");
    }
    return intent;
}

From source file:com.creativtrendz.folio.ui.FolioWebViewScroll.java

@SuppressLint("NewApi")
protected void openFileInput(final ValueCallback<Uri> fileUploadCallbackFirst,
        final ValueCallback<Uri[]> fileUploadCallbackSecond) {
    if (mFileUploadCallbackFirst != null) {
        mFileUploadCallbackFirst.onReceiveValue(null);
    }// w  w  w.  j  ava2  s.c  o  m
    mFileUploadCallbackFirst = fileUploadCallbackFirst;

    if (mFileUploadCallbackSecond != null) {
        mFileUploadCallbackSecond.onReceiveValue(null);
    }
    mFileUploadCallbackSecond = fileUploadCallbackSecond;

    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType(mUploadableFileTypes);

    if (mFragment != null && mFragment.get() != null && Build.VERSION.SDK_INT >= 11) {
        mFragment.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()),
                mRequestCodeFilePicker);
    } else if (mActivity != null && mActivity.get() != null) {
        mActivity.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()),
                mRequestCodeFilePicker);
    }
}

From source file:com.master.metehan.filtereagle.ActivityMain.java

private Intent getIntentLogcat() {
    Intent intent;/*from   w  w w  .  j av  a2 s.  c  o  m*/
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        if (Util.isPackageInstalled("org.openintents.filemanager", this)) {
            intent = new Intent("org.openintents.action.PICK_DIRECTORY");
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(
                    Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager"));
        }
    } else {
        intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TITLE, "logcat.txt");
    }
    return intent;
}

From source file:com.ubuntuone.android.files.activity.FilesActivity.java

private void onUpload(final String type, final int titleResId, boolean openable) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(type);//from   w  w w  .  j ava 2 s  .  c o m
    if (openable) {
        intent.addCategory(Intent.CATEGORY_OPENABLE);
    }
    final Intent chooser = Intent.createChooser(intent, getString(titleResId));
    startActivityForResult(chooser, REQUEST_ADD_FILE);
}

From source file:org.kontalk.ui.ComposeMessageFragment.java

/** Starts an activity for picture attachment selection. */
@TargetApi(Build.VERSION_CODES.KITKAT)//from   w w w .j a  va2 s  .  c  o m
private void selectGalleryAttachment() {
    Intent pictureIntent;

    if (!MediaStorage.isStorageAccessFrameworkAvailable()) {
        pictureIntent = new Intent(Intent.ACTION_GET_CONTENT).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
                .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        pictureIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    }

    pictureIntent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*")
            .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

    startActivityForResult(pictureIntent, SELECT_ATTACHMENT_OPENABLE);
}