private File getOutputPhotoFile() throws IOException { File directory = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), getPackageName()); if (!directory.exists()) { if (!directory.mkdirs()) { Log.e(TAG, "Failed to create storage directory."); return null; } } String timeStamp = new SimpleDateFormat("yyyMMdd_HHmmss", Locale.ENGLISH).format(new Date()); File[] files = directory.listFiles(); File exifVar = new File(directory.getPath(), "IMG_" + timeStamp + ".jpg"); if(files.length!=0) { File newestFile = files[files.length-1]; exifVar = new File(directory.getPath() + File.separator + newestFile.getName()); } String mString = "Generic Text.."; ExifInterface exif = new ExifInterface(exifVar.getAbsolutePath()); exif.setAttribute("UserComment", mString); exif.saveAttributes(); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, String.valueOf(latituteField.toString())); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, String.valueOf(longitudeField.toString())); exif.saveAttributes(); return exifVar; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)