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:com.easemob.ui.ChatActivity.java

/**
 * /*from  w ww  .java  2s . co m*/
 */
private void selectFileFromLocal() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, REQUEST_CODE_SELECT_FILE);
}

From source file:app.view.chat.ChatActivity.java

/**
 * ?//  w w w.  ja  v a  2  s .c o m
 */
public void selectPicFromLocal() {
    Intent intent;
    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");

    } else {
        intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, REQUEST_CODE_LOCAL);
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

/**
 * Starts the uploading experience/*from ww w.  j  av a 2 s. c o m*/
 * @param requestCode The request code that will be used to choose simple/chunked uploading
 */
private void upload(final int requestCode) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType(ACCEPTED_UPLOAD_MIME_TYPES);
    startActivityForResult(intent, requestCode);
}

From source file:net.etuldan.sparss.fragment.EditFeedsListFragment.java

private void importFromOpml() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
            || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
        try {/*w ww  . j a  v  a2  s.  co  m*/
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("file/*");
            startActivityForResult(intent, REQUEST_PICK_OPML_FILE);
        } catch (Exception unused) {
            displayCustomFilePicker();
        }
    } else {
        Toast.makeText(getActivity(), R.string.error_external_storage_not_available, Toast.LENGTH_LONG).show();
    }
}

From source file:com.smp.musicspeed.MainActivity.java

private Intent createAudioContentIntent() {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("audio/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    // intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    return intent;
}

From source file:net.fred.feedex.fragment.EditFeedsListFragment.java

private void importFromOpml() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
            || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {

        // First, try to use a file app
        try {//from w w w . j  a  v  a 2  s.co m
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("file/*");
            startActivityForResult(intent, REQUEST_PICK_OPML_FILE);
        } catch (Exception unused) { // Else use a custom file selector
            displayCustomFilePicker();
        }
    } else {
        Toast.makeText(getActivity(), R.string.error_external_storage_not_available, Toast.LENGTH_LONG).show();
    }
}

From source file:com.viktorrudometkin.burramys.fragment.EditFeedsListFragment.java

private void importFromOpml() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
            || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {

        // First, try to use a file app
        try {/*from  w  w w.j a  va  2s .  c  o m*/
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("text/*");
            startActivityForResult(intent, REQUEST_PICK_OPML_FILE);
        } catch (Exception unused) { // Else use a custom file selector
            displayCustomFilePicker();
        }
    } else {
        UiUtils.showMessage(getActivity(), R.string.error_external_storage_not_available);
    }
}

From source file:com.juick.android.ThreadActivity.java

public void onClick(DialogInterface dialog, int which) {
    Intent intent;//  w w w. j av  a 2  s .co m
    switch (which) {
    case 0:
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        startActivityForResult(Intent.createChooser(intent, null), ACTIVITY_ATTACHMENT_IMAGE);
        break;
    case 1:
        intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        boolean useTempFileForCapture = sp.getBoolean("useTempFileForCapture", true);
        if (useTempFileForCapture) {
            File file = NewMessageActivity.getPhotoCaptureFile();
            file.delete();
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        } else {
            intent.putExtra(MediaStore.EXTRA_OUTPUT,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        }
        startActivityForResult(intent, ACTIVITY_ATTACHMENT_IMAGE);
        break;
    case 2:
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("video/*");
        startActivityForResult(Intent.createChooser(intent, null), ACTIVITY_ATTACHMENT_VIDEO);
        break;
    case 3:
        intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(intent, ACTIVITY_ATTACHMENT_VIDEO);
        break;
    }
}

From source file:com.android.mms.ui.MessageUtils.java

public static void selectAudio(Activity activity, int requestCode) {
    // / M: Code analyze 027, new feature, to improve the performance of
    // Mms. @{/*from www. j a  v a2  s  .com*/
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(MmsContentType.AUDIO_UNSPECIFIED);
    String[] mimeTypess = new String[] { MmsContentType.AUDIO_UNSPECIFIED, MmsContentType.AUDIO_OGG,
            "application/x-ogg" };
    intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypess);
    if (FeatureOption.MTK_DRM_APP) {
        intent.putExtra(OmaDrmStore.DrmIntentExtra.EXTRA_DRM_LEVEL, OmaDrmStore.DrmIntentExtra.LEVEL_SD);
    }
    /// @}
    activity.startActivityForResult(intent, requestCode);
}

From source file:com.android.mms.ui.MessageUtils.java

public static void recordSound(Activity activity, int requestCode, long sizeLimit) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType(MmsContentType.AUDIO_AMR);
    intent.setClassName("com.android.soundrecorder", "com.android.soundrecorder.SoundRecorder");
    intent.putExtra(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES, sizeLimit);
    activity.startActivityForResult(intent, requestCode);
}