I used this code and its working for me to save camera image and getting uri of that image.
btnCamera.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
dialog.dismiss();
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyyMMdd_HHmmss");
String dt = sdf.format(new Date());
imageFile = null;
imageFile = new File(Environment
.getExternalStorageDirectory() + "/FrameFace/",
"Camera_" + dt + ".png");
Log.e("New Camera Image Path:-",
Environment.getExternalStorageDirectory()
+ "/FrameFace/" + "Camera_" + dt + ".png");
if (!imageFile.exists())
imageFile.createNewFile();
imagePath = Environment.getExternalStorageDirectory()
+ "/FrameFace/" + "Camera_" + dt + ".png";
Uri outputFileUri = Uri.fromFile(imageFile);
Intent pictureActionIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
pictureActionIntent.putExtra(MediaStore.EXTRA_OUTPUT,
outputFileUri);
startActivityForResult(pictureActionIntent, TAKE_PICTURE);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case TAKE_PICTURE:
Log.e("result code: ", Integer.toString(Activity.RESULT_OK) + " "
+ Integer.toString(resultCode));
if (resultCode == Activity.RESULT_OK) {
Handler h = new Handler();
h.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(),
FaceCropActivity_dual.class);
// intent.putExtra("imagePath", imagePath);
Log.e("Image Path-------------", "" + imagePath);
intent.putExtra("imagePath", imagePath);
startActivity(intent);
}
}, 500);
}
break;
}
}