if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
hasWriteContactsPermission = checkSelfPermission(Manifest.permission.CAMERA);
if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.CAMERA},
REQUEST_CODE_ASK_PERMISSIONS);
return;
}
} else {
Intent intent = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getPackageManager()) != null) {
File photo = new File(Environment
.getExternalStorageDirectory(),
"Journal" + Utils_class.getID() + ".jpeg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
mSelectedFilePath = photo.getAbsolutePath();
startActivityForResult(intent,
ACTION_TAKE_PICTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
try {
if (resultCode == RESULT_OK) {
if (requestCode == ACTION_TAKE_PICTURE) {
// flag = true;
// new Utils();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkPermissionForStorageForCam();
} else {
Uri selectedImageUri = data.getData();
}
}
}
} catch (Exception e) {
}
}
把你的代碼放在這裏,而不是圖像。 – currarpickt