/** Creates an intents to open the camera application and initiates it */ protected void takeImageWithCamera() { // create Intent to take a picture and return control to the calling application Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // create a file to save the image cameraFileUri = Utils.getNewCameraFileUri(); // set the image file name intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraFileUri); // trigger activity startActivityForResult(intent, Constants.REQUEST_CODE_CAMERA); }
/** * Enables the preview image, first by trying to decode the URI natively into a bitmap If this * fails then the image will be loaded from the uri handled by the system * * @param cameraFileUri - path to the image */ private void setPreviewImageOn(Uri cameraFileUri) { Log.d(toString(), "setPreviewImageOn: "); try { Bitmap b = Utils.getAppFriendlyBitmap(cameraFileUri, getContentResolver()); Log.d(toString(), "bitt.. " + b); if (b == null) throw new IOException("Bitmap returned is null"); setPreviewBitmapImageOn(b); } catch (IOException e) { Log.e(toString(), "bitmap failed to decode : " + e); setPreviewURIImageOn(cameraFileUri); } }