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

public static Intent getPhotoGalleryIntent(Uri photoUri) {
    Intent galleryIntent = new Intent();
    galleryIntent.setType("image/*");
    galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
    addPhotoPickerExtras(galleryIntent, photoUri);
    return galleryIntent;
}

From source file:Main.java

public static Intent startGetPicPhotoAlbum() {
    Intent intent = null;// w  w  w  .  j a  va2 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 choosePicture(Context context) {
    Intent intent3 = new Intent();
    intent3.setType("image/*");
    intent3.setAction(Intent.ACTION_GET_CONTENT);
    ((Activity) context).startActivityForResult(intent3, REQUEST_CHOOSE);
}

From source file:Main.java

public static void chooserPics(Context context, int requestCode) {
    if (context == null) {
        return;/*ww w.  ja va2 s  . co  m*/
    }

    try {
        Intent localIntent = new Intent();
        localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        localIntent.setType("image/*");
        localIntent.setAction(Intent.ACTION_GET_CONTENT);
        if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(Intent.createChooser(localIntent, "Select Picture"),
                    requestCode);
        } else {
            localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(Intent.createChooser(localIntent, "Select Picture"));
        }
    } catch (Exception e) {
    }
}

From source file:Main.java

public static Intent pickFile(String mimeType) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(mimeType);//from   w  w w. ja  va 2 s .  com
    return intent;
}

From source file:Main.java

public static boolean pickFile(Activity activity, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("file/*");
    activity.startActivityForResult(intent, requestCode);
    return true;//from  ww w . j ava  2 s .c  om
}

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.
 * /*  w  w  w .  j a v a2s . 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  ww w .  j av a 2 s.c om
 * @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:com.waz.zclient.pages.main.conversation.AssetIntentsManager.java

@TargetApi(19)
private static String openDocumentAction() {
    return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? Intent.ACTION_OPEN_DOCUMENT
            : Intent.ACTION_GET_CONTENT;
}