@Override public void takePicture(Map<String, String> propertyMap, IMethodResult result) { Logger.T(TAG, "takePicture"); try { Map<String, String> actualPropertyMap = new HashMap<String, String>(); actualPropertyMap.putAll(getPropertiesMap()); actualPropertyMap.putAll(propertyMap); setActualPropertyMap(actualPropertyMap); String outputFormat = actualPropertyMap.get("outputFormat"); String filePath = null; if (!actualPropertyMap.containsKey("fileName")) { filePath = "/sdcard/DCIM/Camera/IMG_" + dateFormat.format(new Date(System.currentTimeMillis())) + ".jpg"; } else { filePath = actualPropertyMap.get("fileName"); } if (outputFormat.equalsIgnoreCase("image")) { filePath = actualPropertyMap.get("fileName") + ".jpg"; Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath); } else if (outputFormat.equalsIgnoreCase("dataUri")) { Logger.T(TAG, "outputFormat: " + outputFormat); } else { throw new RuntimeException("Unknown 'outputFormat' value: " + outputFormat); } Intent intent = null; if (Boolean.parseBoolean(actualPropertyMap.get("useSystemViewfinder"))) { if (outputFormat.equalsIgnoreCase("image")) { values = new ContentValues(); fileUri = RhodesActivity.getContext() .getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); actualPropertyMap.put("captureUri", fileUri.toString()); propertyMap.put("dataURI", ""); // intent is null with MediaStore.EXTRA_OUTPUT so adding fileuri to map and get it with // same key // if instead of MediaStore.EXTRA_OUTPUT any other key is used then the bitmap is null // though the file is getting created intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); } else if (outputFormat.equalsIgnoreCase("dataUri")) { } } else { intent = new Intent(ContextFactory.getUiContext(), CameraActivity.class); intent.putExtra(CameraExtension.INTENT_EXTRA_PREFIX + "CAMERA_ID", getId()); } ((CameraFactory) CameraFactorySingleton.getInstance()) .getRhoListener() .setMethodResult(result); ((CameraFactory) CameraFactorySingleton.getInstance()) .getRhoListener() .setActualPropertyMap(actualPropertyMap); RhodesActivity.safeGetInstance() .startActivityForResult( intent, RhoExtManager.getInstance() .getActivityResultNextRequestCode(CameraRhoListener.getInstance())); } catch (RuntimeException e) { Logger.E(TAG, e); result.setError(e.getMessage()); } }
@Override public void onCreateApplication(IRhoExtManager extManager) { CameraFactorySingleton.setInstance(this); }