将GPS坐标写入Android中的照片文件
我看了很多问题,但还是很困惑 我想在我的文件中添加exif块,在哪里以及如何执行此操作 我不熟悉Android编程语言。我有一个相机代码,我生成了一个具有唯一名称的照片文件,它将照片顺利地保存在SD卡上我自己创建的目录中。但是,我无法判断如何将ExiFinInterface插入我的照片文件。我想分配gps坐标,我有一个location listener类正在工作,我将从中获取Lattitude经度字符串,用于设置Exif块的属性将GPS坐标写入Android中的照片文件,android,gps,photo,exif,Android,Gps,Photo,Exif,我看了很多问题,但还是很困惑 我想在我的文件中添加exif块,在哪里以及如何执行此操作 我不熟悉Android编程语言。我有一个相机代码,我生成了一个具有唯一名称的照片文件,它将照片顺利地保存在SD卡上我自己创建的目录中。但是,我无法判断如何将ExiFinInterface插入我的照片文件。我想分配gps坐标,我有一个location listener类正在工作,我将从中获取Lattitude经度字符串,用于设置Exif块的属性 ExifInterface exif = new ExifInte
ExifInterface exif = new ExifInterface(string filepath);
这个命令需要文件路径字符串,我用两种方法生成文件
public static File getPhotoDirectory() {
File outputDir = null;
String externalStorageState = Environment.getExternalStorageState();
if (externalStorageState.equals(Environment.MEDIA_MOUNTED)) {
File pictureDir =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
outputDir = new File(pictureDir, "HasanDirectory");
if(!outputDir.exists()) {
if(!outputDir.mkdirs()) {
String message = "Failed to create directory:" + outputDir.getAbsolutePath();
Log.e(LOG_TAG, message);
outputDir = null;
}
}
}
return outputDir;
}
public static File generateTimeStampPhotoFile() {
File photoFile = null;
File outputDir = getPhotoDirectory();
if (outputDir != null) {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//if (type == MEDIA_TYPE_IMAGE){
picCount++; // "HA" provides a unique number to each pic
String photoFileName = "IMG_" + timeStamp + "_" + picCount + ".jpg";
photoFile = new File(outputDir, photoFileName);
}
return photoFile;
}
指导我如何添加exif块
或者,如果你读到这里,请?为图片指定GPS坐标的其他方法有哪些?android中照相机类的setParameters功能有效吗?请查看这篇文章:我每次都在制作一个新的照片文件。一个带有时间戳和piccount的名称,我想为每个图片指定坐标。那么在新ExiFinterFanc中写什么如何在此处提取每个照片的路径函数generateTimeStampPhotoFile返回一个文件对象。所以我猜在你保存照片文件后,立即调用exif例程。。。exif=新的ExiFinterface YourPhotoFileVariable.getCanonicalPath;正如您所提到的,当我在onPictureJpegbyte[]字节上捕获时调用generateTimeStampPhotoFile时,我的文件被保存,Camera。。