80,351
社区成员
发帖
与我相关
我的任务
分享
private void openCamera() {
String path = activity.getExternalFilesDir(Environment.DIRECTORY_DCIM).getPath() + File.separator + "File.png";
File mFile = new File(path);
try {
if (!mFile.exists()) {
mFile.createNewFile();
} else {
mFile.delete();
mFile.createNewFile();
}
} catch (IOException e) {
e.printStackTrace();
}
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mFile));
activity.startActivityForResult(intent, RESULT_OPENCAMERA_LOAD_IMAGE);
}