//在调用之前增加以下三行
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
File dir = new File(Environment.getExternalStorageDirectory());
if (!dir.exists()) dir.mkdirs();
imgIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
localTempImgFileName = System.currentTimeMillis() + ".jpg";
File f = new File(dir, localTempImgFileName);
Uri u = Uri.fromFile(f);
imgIntent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
imgIntent.putExtra(MediaStore.EXTRA_OUTPUT, u);
startActivityForResult(imgIntent, getResources().getInteger(R.integer.TAKE_PICTURE));
android 7.0以上版本调用摄像头拍照失败的解决方法
最新推荐文章于 2022-03-25 16:08:56 发布