我试图允许用户从其设备中选择图像或视频,但目前它仅显示视频或图像,具体取决于以下代码中首先写入的内容:
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//set type to include video too
galleryIntent.setType("image/*, video/*");
startActivityForResult(galleryIntent, GALLERY_IMAGE_REQUEST_CODE);
}
};
不知道我做错了什么,但settype似乎是对的,我试着在图像和视频之间加上或不加逗号…
最佳答案
case 2: //Choose Pic
Intent choosePhotoIntent = new Intent(Intent.ACTION_GET_CONTENT);
choosePhotoIntent.setType("image/*");
startActivityForResult(choosePhotoIntent, PICK_PHOTO_REQUEST);
break;
case 3: //Choose Video
Intent chooseVideoIntent = new Intent(Intent.ACTION_GET_CONTENT);
chooseVideoIntent.setType("video/*");
Toast.makeText(MyActivity.this,getString(R.string.video_message), Toast.LENGTH_LONG).show();
startActivityForResult(chooseVideoIntent, PICK_VIDEO_REQUEST);
break;
试试上面的..你需要有不同的选择..