/**
* 调用系统相机
*/
public String openCamera(int requestCode) {
String cameraPath = Environment.getExternalStorageDirectory().getPath() + "/" + context.getPackageName() + "/camera/";
//调用系统自带相机
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(cameraPath);
if (!file.exists()) {
file.mkdirs();
}
//拍摄照片时的毫秒值(用来当做图片的名称)
long time = System.currentTimeMillis();
File path = new File(cameraPath, time + ".png");
ContentValues contentValues = new ContentValues(1);
contentValues.put(MediaStore.Images.Media.DATA, path.getAbsolutePath());
Uri uri = context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,contentValues);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, requestCode);
return path.getPath();
}
Android打开系统相机 适配Android7.0
最新推荐文章于 2018-10-08 16:30:01 发布