标签:storage out int his start tar current pat cti
安卓11有权限要求,以下方法管用
//跳转到相机
private void showCamera() {
File fileDir = new File(Environment.getExternalStorageDirectory(),"Pictures");
if (!fileDir.exists()){
fileDir.getParentFile().mkdir();
}
filePath = fileDir.getAbsolutePath() + "/IMG_" + System.currentTimeMillis() + ".jpg";
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (Build.VERSION.SDK_INT > 24){
imageUri = FileProvider.getUriForFile(this,this.getPackageName() + ".fileprovider",
new File(filePath));
}
else {
imageUri = Uri.fromFile(new File(filePath));
}
intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
startActivityForResult(intent,TAKE_PHOTO);
}
标签:storage out int his start tar current pat cti
原文地址:https://www.cnblogs.com/wuren-best/p/14823767.html