android.provider.MediaStore#ACTION_VIDEO_CAPTURE源码实例Demo

下面列出了android.provider.MediaStore#ACTION_VIDEO_CAPTURE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private Uri getOutputFilename(String intentType) {
    String prefix = "";
    String suffix = "";

    if (intentType == MediaStore.ACTION_IMAGE_CAPTURE) {
        prefix = "image-";
        suffix = ".jpg";
    } else if (intentType == MediaStore.ACTION_VIDEO_CAPTURE) {
        prefix = "video-";
        suffix = ".mp4";
    }

    String packageName = getReactApplicationContext().getPackageName();
    File capturedFile = null;
    try {
        capturedFile = createCapturedFile(prefix, suffix);
    } catch (IOException e) {
        Log.e("CREATE FILE", "Error occurred while creating the File", e);
        e.printStackTrace();
    }
    return FileProvider.getUriForFile(getReactApplicationContext(), packageName+".fileprovider", capturedFile);
}
 
源代码2 项目: YImagePicker   文件: CameraCompat.java
private static Intent getTakeVideoIntent(Activity activity, Uri imageUri, long maxDuration) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        if (Build.VERSION.SDK_INT < 21) {
            List<ResolveInfo> resInfoList = activity.getPackageManager()
                    .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo resolveInfo : resInfoList) {
                String packageName = resolveInfo.activityInfo.packageName;
                activity.grantUriPermission(packageName, imageUri,
                        Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }
        }
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        if (maxDuration > 1) {
            intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, maxDuration / 1000L);
        }
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    }
    return intent;
}
 
源代码3 项目: actor-platform   文件: MediaPickerFragment.java
public void requestVideo() {
    this.pickCropped = false;

    //
    // Generating Temporary File Name
    //
    pendingFile = generateRandomFile(".mp4");
    if (pendingFile == null) {
        return;
    }


    //
    // Requesting Video
    //
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(pendingFile)));
    startActivityForResult(intent, REQUEST_VIDEO);
}
 
源代码4 项目: lbry-android   文件: MainActivity.java
public void requestVideoCapture() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (intent.resolveActivity(getPackageManager()) != null) {
        String outputPath = String.format("%s/record", Utils.getAppInternalStorageDir(this));
        File dir = new File(outputPath);
        if (!dir.isDirectory()) {
            dir.mkdirs();
        }

        cameraOutputFilename = String.format("%s/VID_%s.mp4", outputPath, Helper.FILESTAMP_FORMAT.format(new Date()));
        Uri outputUri = FileProvider.getUriForFile(this, String.format("%s.fileprovider", getPackageName()), new File(cameraOutputFilename));
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
        startActivityForResult(intent, REQUEST_VIDEO_CAPTURE);
        return;
    }

    showError(getString(R.string.cannot_capture_video));
}
 
源代码5 项目: SiliCompressor   文件: SelectPictureActivity.java
private void dispatchTakeVideoIntent() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeVideoIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        try {

            takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);
            takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            capturedUri = FileProvider.getUriForFile(this,
                    getPackageName() + FILE_PROVIDER_AUTHORITY,
                    createMediaFile(TYPE_VIDEO));

            takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedUri);
            Log.d(LOG_TAG, "VideoUri: " + capturedUri.toString());
            startActivityForResult(takeVideoIntent, REQUEST_TAKE_VIDEO);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
 
源代码6 项目: android-utils   文件: MediaUtils.java
/**
 * Creates an intent to take a video from camera or gallery or any other application that can
 * handle the intent.
 *
 * @param ctx
 * @param savingUri
 * @param durationInSeconds
 * @return
 */
public static Intent createTakeVideoIntent(Activity ctx, Uri savingUri, int durationInSeconds) {

    if (savingUri == null) {
        throw new NullPointerException("Uri cannot be null");
    }

    final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    final PackageManager packageManager = ctx.getPackageManager();
    final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        final String packageName = res.activityInfo.packageName;
        final Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        intent.setPackage(packageName);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, savingUri);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationInSeconds);
        cameraIntents.add(intent);
    }

    // Filesystem.
    final Intent galleryIntent = new Intent();
    galleryIntent.setType("video/*");
    galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

    // Chooser of filesystem options.
    final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");

    // Add the camera options.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));

    return chooserIntent;
}
 
源代码7 项目: mobilecloud-15   文件: VideoListActivity.java
/**
 * Displays a chooser dialog that gives options
 * to upload video from either by Gallery or by 
 * VideoRecorder.
 */
private void displayChooserDialog() {
    // Create an intent that will start an Activity to
    // get Video from Gallery.
    final Intent videoGalleryIntent =
        new Intent(Intent.ACTION_GET_CONTENT)
              .setType("video/*")
              .putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    
    // Create an intent that will start an Activity to
    // Record the Video.
    final Intent recordVideoIntent =
        new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    // Intent that wraps the given target Intent and
    // shows a chooser dialog to show the Apps that 
    // can handle the target Intent.
    final Intent chooserIntent =
        Intent.createChooser(videoGalleryIntent, "Upload Video via");

    // Add RecordVideo Intent, so that App that can
    // record video is added to the chooser dialog.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                           new Intent[] { recordVideoIntent });
    
    // Starts an Activity to get the Video either by Gallery
    // or by VideoRecorder.
    startActivityForResult(chooserIntent, REQUEST_GET_VIDEO);

}
 
private Intent getVideoIntent() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // @todo from experience, for Videos we get the data onActivityResult
    // so there's no need to store the Uri
    Uri outputVideoUri = getOutputUri(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputVideoUri);
    return intent;
}
 
源代码9 项目: droid-stealth   文件: ContentFragment.java
/**
 * Called when a MenuItem is clicked. Handles adding of items
 *
 * @param item
 * @return
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case R.id.content_add:
			Intent getContentIntent = FileUtils.createGetContentIntent();
			Intent intent = Intent.createChooser(getContentIntent, "Select a file");
			((HomeActivity) getActivity()).setRequestedActivity(true);
			startActivityForResult(intent, REQUEST_CHOOSER);
			return true;
		case R.id.content_image_capture:
			mTempResultFile = Utils.getRandomCacheFile(".jpg");
			Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
			cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempResultFile));
			((HomeActivity) getActivity()).setRequestedActivity(true);
			startActivityForResult(cameraIntent, CONTENT_REQUEST);
			return true;
		case R.id.content_video_capture:
			mTempResultFile = Utils.getRandomCacheFile(".mp4");
			Intent videoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
			videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempResultFile));
			((HomeActivity) getActivity()).setRequestedActivity(true);
			startActivityForResult(videoIntent, CONTENT_REQUEST);
			return true;
		case R.id.content_audio_capture:
			mTempResultFile = Utils.getRandomCacheFile(".3gp");
			((HomeActivity) getActivity()).setRequestedActivity(true);

			Intent audioIntent = new Intent(getActivity(), RecorderActivity.class);
			audioIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mTempResultFile));
			startActivityForResult(audioIntent, CONTENT_REQUEST);
			return true;
		default:
			return super.onOptionsItemSelected(item);
	}
}
 
源代码10 项目: q-municate-android   文件: MediaUtils.java
public static void startCameraVideoForResult(Fragment fragment) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (intent.resolveActivity(App.getInstance().getPackageManager()) == null) {
        return;
    }

    File videoFile = getTemporaryCameraFileVideo();
    Uri uri = getValidUri(videoFile, fragment.getContext());
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, ConstsCore.VIDEO_QUALITY_HIGH);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, ConstsCore.MAX_RECORD_DURATION_IN_SEC);
    fragment.startActivityForResult(intent, CAMERA_VIDEO_REQUEST_CODE);
}
 
源代码11 项目: android-utils   文件: Utils.java
/**
 * @param ctx
 * @param savingUri
 * @param durationInSeconds
 * @return
 * @deprecated Use {@link MediaUtils#createTakeVideoIntent(Activity, Uri, int)}
 * Creates an intent to take a video from camera or gallery or any other application that can
 * handle the intent.
 */
public static Intent createTakeVideoIntent(Activity ctx, Uri savingUri, int durationInSeconds) {

    if (savingUri == null) {
        throw new NullPointerException("Uri cannot be null");
    }

    final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    final PackageManager packageManager = ctx.getPackageManager();
    final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        final String packageName = res.activityInfo.packageName;
        final Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        intent.setPackage(packageName);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, savingUri);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationInSeconds);
        cameraIntents.add(intent);
    }

    // Filesystem.
    final Intent galleryIntent = new Intent();
    galleryIntent.setType("video/*");
    galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

    // Chooser of filesystem options.
    final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");

    // Add the camera options.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));

    return chooserIntent;
}
 
源代码12 项目: androidnative.pri   文件: VideoPicker.java
static void takeVideo(Map message) {
    if (message.containsKey("broadcast")) {
        broadcast = (Boolean) message.get("broadcast");
    }

   Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
   Activity activity = org.qtproject.qt5.android.QtNative.activity();
   if (takeVideoIntent.resolveActivity(activity.getPackageManager()) != null) {
       activity.startActivityForResult(takeVideoIntent, TAKE_VIDEO_ACTION );
   }
}
 
源代码13 项目: matrix-android-console   文件: RoomActivity.java
/**
 * Launch the camera
 */
private void launchVideo() {
    final Intent captureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // lowest quality
    captureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    RoomActivity.this.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            startActivityForResult(captureIntent, TAKE_VIDEO);
        }
    });
}
 
源代码14 项目: Android-Basics-Codes   文件: MainActivity.java
public void click2(View v){
	//����ϵͳ�Դ����������
	Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
	//ָ����Ƶ����·��
	intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File("sdcard/haha.3gp")));
	//ָ����������
	intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
	startActivityForResult(intent, 20);
}
 
源代码15 项目: patrol-android   文件: VideoModeActivity.java
private void dispatchTakeVideoIntent() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    dist = FilesUtils.getOutputExternalMediaFile(FilesUtils.MEDIA_TYPE_VIDEO);
    ContentValues value = new ContentValues();
    value.put(MediaStore.Video.Media.TITLE, dist.getName());
    value.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
    value.put(MediaStore.Video.Media.DATA, dist.getAbsolutePath());
    Uri videoUri = getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, value);
    takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
    takeVideoIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,60); //60 sec
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
    }
}
 
源代码16 项目: Camera2   文件: VideoCaptureIntentTest.java
@Override
protected void setUp() throws Exception
{
    super.setUp();
    mIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
}
 
源代码17 项目: android-chromium   文件: SelectFileDialog.java
/**
 * Creates and starts an intent based on the passed fileTypes and capture value.
 * @param fileTypes MIME types requested (i.e. "image/*")
 * @param capture The capture value as described in http://www.w3.org/TR/html-media-capture/
 * @param window The WindowAndroid that can show intents
 */
@CalledByNative
private void selectFile(String[] fileTypes, boolean capture, WindowAndroid window) {
    mFileTypes = new ArrayList<String>(Arrays.asList(fileTypes));
    mCapture = capture;

    Intent chooser = new Intent(Intent.ACTION_CHOOSER);
    Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    mCameraOutputUri = Uri.fromFile(getFileForImageCapture());
    camera.putExtra(MediaStore.EXTRA_OUTPUT, mCameraOutputUri);
    Intent camcorder = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    Intent soundRecorder = new Intent(
            MediaStore.Audio.Media.RECORD_SOUND_ACTION);

    // Quick check - if the |capture| parameter is set and |fileTypes| has the appropriate MIME
    // type, we should just launch the appropriate intent. Otherwise build up a chooser based on
    // the accept type and then display that to the user.
    if (captureCamera()) {
        if (window.showIntent(camera, this, R.string.low_memory_error)) return;
    } else if (captureCamcorder()) {
        if (window.showIntent(camcorder, this, R.string.low_memory_error)) return;
    } else if (captureMicrophone()) {
        if (window.showIntent(soundRecorder, this, R.string.low_memory_error)) return;
    }

    Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getContentIntent.addCategory(Intent.CATEGORY_OPENABLE);
    ArrayList<Intent> extraIntents = new ArrayList<Intent>();
    if (!noSpecificType()) {
        // Create a chooser based on the accept type that was specified in the webpage. Note
        // that if the web page specified multiple accept types, we will have built a generic
        // chooser above.
        if (shouldShowImageTypes()) {
            extraIntents.add(camera);
            getContentIntent.setType(ALL_IMAGE_TYPES);
        } else if (shouldShowVideoTypes()) {
            extraIntents.add(camcorder);
            getContentIntent.setType(ALL_VIDEO_TYPES);
        } else if (shouldShowAudioTypes()) {
            extraIntents.add(soundRecorder);
            getContentIntent.setType(ALL_AUDIO_TYPES);
        }
    }

    if (extraIntents.isEmpty()) {
        // We couldn't resolve an accept type, so fallback to a generic chooser.
        getContentIntent.setType(ANY_TYPES);
        extraIntents.add(camera);
        extraIntents.add(camcorder);
        extraIntents.add(soundRecorder);
    }

    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            extraIntents.toArray(new Intent[] { }));

    chooser.putExtra(Intent.EXTRA_INTENT, getContentIntent);

    if (!window.showIntent(chooser, this, R.string.low_memory_error)) {
        onFileNotSelected();
    }
}
 
源代码18 项目: android-chromium   文件: SelectFileDialog.java
/**
 * Creates and starts an intent based on the passed fileTypes and capture value.
 * @param fileTypes MIME types requested (i.e. "image/*")
 * @param capture The capture value as described in http://www.w3.org/TR/html-media-capture/
 * @param window The WindowAndroid that can show intents
 */
@CalledByNative
private void selectFile(String[] fileTypes, boolean capture, WindowAndroid window) {
    mFileTypes = new ArrayList<String>(Arrays.asList(fileTypes));
    mCapture = capture;

    Intent chooser = new Intent(Intent.ACTION_CHOOSER);
    Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    mCameraOutputUri = Uri.fromFile(getFileForImageCapture());
    camera.putExtra(MediaStore.EXTRA_OUTPUT, mCameraOutputUri);
    Intent camcorder = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    Intent soundRecorder = new Intent(
            MediaStore.Audio.Media.RECORD_SOUND_ACTION);

    // Quick check - if the |capture| parameter is set and |fileTypes| has the appropriate MIME
    // type, we should just launch the appropriate intent. Otherwise build up a chooser based on
    // the accept type and then display that to the user.
    if (captureCamera()) {
        if (window.showIntent(camera, this, R.string.low_memory_error)) return;
    } else if (captureCamcorder()) {
        if (window.showIntent(camcorder, this, R.string.low_memory_error)) return;
    } else if (captureMicrophone()) {
        if (window.showIntent(soundRecorder, this, R.string.low_memory_error)) return;
    }

    Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getContentIntent.addCategory(Intent.CATEGORY_OPENABLE);
    ArrayList<Intent> extraIntents = new ArrayList<Intent>();
    if (!noSpecificType()) {
        // Create a chooser based on the accept type that was specified in the webpage. Note
        // that if the web page specified multiple accept types, we will have built a generic
        // chooser above.
        if (shouldShowImageTypes()) {
            extraIntents.add(camera);
            getContentIntent.setType(ALL_IMAGE_TYPES);
        } else if (shouldShowVideoTypes()) {
            extraIntents.add(camcorder);
            getContentIntent.setType(ALL_VIDEO_TYPES);
        } else if (shouldShowAudioTypes()) {
            extraIntents.add(soundRecorder);
            getContentIntent.setType(ALL_AUDIO_TYPES);
        }
    }

    if (extraIntents.isEmpty()) {
        // We couldn't resolve an accept type, so fallback to a generic chooser.
        getContentIntent.setType(ANY_TYPES);
        extraIntents.add(camera);
        extraIntents.add(camcorder);
        extraIntents.add(soundRecorder);
    }

    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            extraIntents.toArray(new Intent[] { }));

    chooser.putExtra(Intent.EXTRA_INTENT, getContentIntent);

    if (!window.showIntent(chooser, this, R.string.low_memory_error)) {
        onFileNotSelected();
    }
}
 
public boolean showFileChooser(ValueCallback<Uri> uploadFile, String acceptType,
        String capture) {
    mFilePathCallback = uploadFile;

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(mActivity.getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = createImageFile();
        // Continue only if the File was successfully created
        if (photoFile != null) {
            mCameraPhotoPath = PATH_PREFIX + photoFile.getAbsolutePath();
            takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
        } else {
            takePictureIntent = null;
        }
    }

    Intent camcorder = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    Intent soundRecorder = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    ArrayList<Intent> extraIntents = new ArrayList<Intent>();

    // A single mime type.
    if (!(acceptType.contains(SPLIT_EXPRESSION) || acceptType.contains(ANY_TYPES))) {
        if (capture.equals("true")) {
            if (acceptType.startsWith(IMAGE_TYPE)) {
                if (takePictureIntent != null) {
                    mActivity.startActivityForResult(takePictureIntent, INPUT_FILE_REQUEST_CODE);
                    Log.d(TAG, "Started taking picture");
                    return true;
                }
            } else if (acceptType.startsWith(VIDEO_TYPE)) {
                mActivity.startActivityForResult(camcorder, INPUT_FILE_REQUEST_CODE);
                Log.d(TAG, "Started camcorder");
                return true;
            } else if (acceptType.startsWith(AUDIO_TYPE)) {
                mActivity.startActivityForResult(soundRecorder, INPUT_FILE_REQUEST_CODE);
                Log.d(TAG, "Started sound recorder");
                return true;
            }
        } else {
            if (acceptType.startsWith(IMAGE_TYPE)) {
                if (takePictureIntent != null) {
                    extraIntents.add(takePictureIntent);
                }
                contentSelectionIntent.setType(ALL_IMAGE_TYPES);
            } else if (acceptType.startsWith(VIDEO_TYPE)) {
                extraIntents.add(camcorder);
                contentSelectionIntent.setType(ALL_VIDEO_TYPES);
            } else if (acceptType.startsWith(AUDIO_TYPE)) {
                extraIntents.add(soundRecorder);
                contentSelectionIntent.setType(ALL_AUDIO_TYPES);
            }
        }
    }

    // Couldn't resolve an accept type.
    if (extraIntents.isEmpty() && canWriteExternalStorage()) {
        if (takePictureIntent != null) {
            extraIntents.add(takePictureIntent);
        }
        extraIntents.add(camcorder);
        extraIntents.add(soundRecorder);
        contentSelectionIntent.setType(ANY_TYPES);
    }

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    if (!extraIntents.isEmpty()) {
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                extraIntents.toArray(new Intent[] { }));
    }
    mActivity.startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
    Log.d(TAG, "Started chooser");
    return true;
}
 
private Intent createCamcorderIntent() {
    return new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
}