// calling hardware camera
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
output = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
"my_app_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, output);
startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE);
// OnActivityresult :
// Store the image in a file to upload to server
bitmap =decodeUri(output);
File file = new File(Environment.getExternalStorageDirectory() + "/myimage.jpeg");
FileOutputStream fOut = new FileOutputStream(file);
bitmap = (Bitmap) data.getExtras().get("data");
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fOut);
//imageview img;
img.setImageBitmap(bitmap);