Open AndroidLMY opened 4 years ago
同问
MediaStoreCompat mMediaStoreCompat = new MediaStoreCompat(this);
mMediaStoreCompat.setCaptureStrategy(new CaptureStrategy(true,getPackageName()+".fileprovider"));
mMediaStoreCompat.dispatchCaptureIntent(this,CALL_CAMERA_ACTIVITY_REQUEST_CODE);
源码是这样的
我这样写了 能够调用相机拍照但是返回回调到onActivityResult Intent data这个回调参数为空 不知道什么原因
用这个就可以 mMediaStoreCompat.getCurrentPhotoUri()
File dir = new File(Environment.getExternalStorageDirectory(), "pictures");
if (dir.exists()) {
dir.mkdirs();
}
currentImageFile = new File(dir, System.currentTimeMillis() + ".webp");
if (!currentImageFile.exists()) {
try {
currentImageFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
it.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(currentImageFile));
startActivityForResult(it, Activity.DEFAULT_KEYS_DIALER);
不通过相册里面的拍照 如何外部代码调用相机拍宅