android7.0打开系统相机

/**

* 打开系统相机

*/

private voidxitongCarmar(){

if(ContextCompat.checkSelfPermission(getContext(),Manifest.permission.WRITE_EXTERNAL_STORAGE)

!= PackageManager.PERMISSION_GRANTED) {

CustomHintUtil.showMessage(mContext,"当前没有权限",null,null,null);

return;

}

pictrueFile=newFile(Environment.getExternalStorageDirectory(),"/cake/img/"+System.currentTimeMillis()+".png");

if(pictrueFile.getParentFile().isDirectory()

&&!pictrueFile.getParentFile().exists())

pictrueFile.getParentFile().mkdirs();

intcurrentSystemV= Build.VERSION.SDK_INT;

Intent intent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);

if(currentSystemV<24)//andorid7.0适配

intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(pictrueFile));

else{

ContentValues contentValues=newContentValues(1);

contentValues.put(MediaStore.Images.Media.DATA,pictrueFile.getAbsolutePath());

Uri uri=getmContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,contentValues);

intent.putExtra(MediaStore.EXTRA_OUTPUT,uri);

}

mContext.startActivityForResult(intent,REQUEST_CAMERA);

}


android7.0打开系统相机_第1张图片

你可能感兴趣的:(android7.0打开系统相机)