// 相册选取
Intent intent = new Intent(Intent.ACTION_GET_CONTENT).setType("image/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(intent, Constants.REQUEST_CODE_GALLERY);
// 相册选取
Intent intent = new Intent(
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, Constants.REQUEST_CODE_GALLERY);
// 拍照
File temp = new File(PicUtils.PATH);
Uri imageFileUri = Uri.fromFile(temp);//获取文件的Uri
Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//跳转到相机Activity
it.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);//告诉相机拍摄完毕输出图片到指定的Uri
startActivityForResult(it, Constants.REQUEST_CODE_PHOTOGRAPH);
android 相册 相机 获取相片 相册 2中方式
最新推荐文章于 2023-10-08 21:37:51 发布