Please try the code snippet below, and change it where you need to. Warning: I haven't tested it.
So, basically, what I did is this:
- Step 1. Get the byte array from the camera in the onPictureTaken method.
- Step 2. Create a file on the SDCard and write the byte array to the file
Step 3. Read Exif Metadata from File-Path
@Override public void onPictureTaken(byte[] data, Camera camera) { //Step 1. Create file for storing image data on SDCard File sdDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File pictureFileDir = new File(sdDir, "RDCCameraImages"); if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) { Log.d(TAG, "Can't create directory to save image."); return; } //Step 2. write image byte array to file String photoFile = "Picture_" + date + ".jpg"; String imageFilePath = pictureFileDir.getPath() + File.separator + photoFile; File pictureFile = new File(imageFilePath); try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); Toast.makeText(context, "New Image saved:" + photoFile, Toast.LENGTH_LONG).show(); } catch (Exception error) { Log.d(TAG, "File" + filename + "not saved: " + error.getMessage()); Toast.makeText(context, "Image could not be saved.", Toast.LENGTH_LONG).show(); } //Step 3. Get Exif Info from File path ExifInterface exif; try { exif = new ExifInterface(imageFilePath); String make = exif.getAttribute(ExifInterface.TAG_MAKE); } catch (IOException e) { e.printStackTrace(); } //check the value of “make” here
}