Android Intent for Capturing both Images and Videos?

前端 未结 3 821
陌清茗
陌清茗 2020-12-29 04:15

Is there an Intent for starting a camera with options to capture both Pictures and Videos on Android?

I\'ve used both MediaStore.ACTION_VIDEO_CAPTURE and MediaStore.

3条回答
  •  鱼传尺愫
    2020-12-29 04:57

    I achieved it :) You can do it by following --

        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
                contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
                contentSelectionIntent.setType("*/*");
        intentArray = new Intent[]{takePictureIntent,takeVideoIntent};
        chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
        chooserIntent.putExtra(Intent.EXTRA_TITLE, "Choose an action");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
        startActivityForResult(chooserIntent, 1);
    

    Similar example here

    Happy coding :)

提交回复
热议问题