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:Main.java

public static void openImageAction(Activity activity, int requestCode) {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void choosePicFromGalley(Context context) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);//ACTION_OPEN_DOCUMENT
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/jpeg");

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        ((Activity) context).startActivityForResult(intent, CHOOSE_GALLERY);
    } else {//from w  w  w .  jav  a2  s .  com
        ((Activity) context).startActivityForResult(intent, CHOOSE_GALLERY);
    }
}

From source file:Main.java

public static Intent startGetPicPhotoAlbum() {
    Intent intent = null;/*from  w ww  . j  a  v  a2  s  .  c  o m*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    } else {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
    }
    intent.setType("image/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}

From source file:Main.java

public static void openFileBrowser(Activity a, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    a.startActivityForResult(intent, requestCode);
}

From source file:Main.java

/**
 * Get the Intent for selecting content to be used in an Intent Chooser.
 * //from ww  w  .j  a  va2  s  . co m
 * @return The intent for opening a file with Intent.createChooser()
 * 
 * @author paulburke
 */
public static Intent createGetContentIntent() {
    // Implicitly allow the user to select a particular kind of data
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // The MIME data type filter
    intent.setType("*/*");
    // Only return URIs that can be opened with ContentResolver
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}

From source file:Main.java

/**
 * Returns an intent calling the android chooser. The chooser will provide apps, which listen to one of the following actions
 * {@link Intent#ACTION_GET_CONTENT} , {@link MediaStore#ACTION_IMAGE_CAPTURE}, {@link MediaStore#ACTION_VIDEO_CAPTURE},
 * {@link MediaStore.Audio.Media#RECORD_SOUND_ACTION}
 * /*from w ww . j a v  a  2s  . com*/
 * @return Intent that opens the app chooser.
 */
public static Intent getChooserIntent() {
    // GET_CONTENT Apps
    Intent getContentIntent = new Intent();
    getContentIntent.setAction(Intent.ACTION_GET_CONTENT);
    getContentIntent.setType("*/*");
    getContentIntent.addCategory(Intent.CATEGORY_OPENABLE);
    // ACTION_IMAGE_CAPTURE Apps
    Intent captureImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // ACTION_VIDEO_CAPTURE Apps
    Intent captureVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // RECORD_SOUND_ACTION Apps
    Intent recordSoungIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
    Intent finalIntent = Intent.createChooser(getContentIntent, "test");
    finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            new Intent[] { captureImageIntent, captureVideoIntent, recordSoungIntent });
    return finalIntent;
}

From source file:org.adaway.helper.ImportExportHelper.java

/**
 * Opens file manager to open file and return it in onActivityResult in Activity
 *
 * @param activity/*  w  ww  .jav a2s.  c  om*/
 */
public static void openFileStream(final FragmentActivity activity) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("text/plain");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        activity.startActivityForResult(intent, REQUEST_CODE_IMPORT);
    } catch (ActivityNotFoundException e) {
        ActivityNotFoundDialogFragment notFoundDialog = ActivityNotFoundDialogFragment.newInstance(
                R.string.no_file_manager_title, R.string.no_file_manager,
                "market://details?id=org.openintents.filemanager", "OI File Manager");

        notFoundDialog.show(activity.getSupportFragmentManager(), "notFoundDialog");
    }
}

From source file:org.jak_linux.dns66.ItemActivity.java

public void performFileSearch() {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);

    startActivityForResult(intent, READ_REQUEST_CODE);
}

From source file:org.chromium.ChromeFileSystem.java

/**
 * Choose a file from the file system.//www  . j  ava  2s .co m
 * @throws JSONException
 */
public void chooseFile(JSONArray mimeTypes) throws JSONException {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // Intent.setType doesn't support handling multiple mime types, so we need to settle on one.
    intent.setType(getIntentType(mimeTypes));

    if (this.cordova != null) {
        this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, "Get File"), 0);
    }
}

From source file:id.nci.stm_9.FileHelper.java

private static Intent buildFileIntent(String filename, String mimeType) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    intent.setData(Uri.parse("file://" + filename));
    intent.setType(mimeType);//from   w  w w  . j a  va  2s  .  co  m

    return intent;
}