很多时候我们都要对我们的图片信息进行一些处理,比如向图片中写入经纬度,拍摄时间,设备信息,作者等等。

这个时候我们就要对我们的图片Exif进行写入信息的操作,当然,我们想知道图片的Exif信息,也可以对Exif信息的读取操作。

因为Android本身有对图片Exif操作的方法,所以就不需要额外导入其他 jar

下面先贴出代码:

import android.media.ExifInterface;import android.util.Log;import java.io.IOException;/** * Created by long on 2016/3/22. */public class ModifyExif {    private static ExifInterface exif = null;    //设置exif    public static void setExif            (String filepath,String longitude,String latitude,String time){        try{            exif = new ExifInterface(filepath);     //根据图片的路径获取图片的Exif        }catch (IOException ex){            Log.e("Mine","cannot read exif",ex);        }        exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,longitude);    //把经度写进exif        exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude);     //把纬度写进exif        exif.setAttribute(ExifInterface.TAG_DATETIME,time);              //把时间写进exif        exif.setAttribute(ExifInterface.TAG_MAKE,longitude);             //把经度写进MAKE 设备的制造商,当然这样也是可以的,大家都是Stirng类型        exif.setAttribute(ExifInterface.TAG_MODEL,latitude);             //把纬度写进MODEL        try{            exif.saveAttributes();         //最后保存起来        }catch (IOException e){            Log.e("Mine","cannot save exif",e);        }    }    //获取exif    public static ExifInterface getExif(String filepath){        try {            exif = new ExifInterface(filepath);    //想要获取相应的值:exif.getAttribute("对应的key");比如获取时间:exif.getAttribute(ExifInterface.TAG_DATETIME);        } catch (Exception e) {            e.printStackTrace();        }        return exif;    } }

相应文章分享:

http://blog.csdn.net/xywy2008/article/details/38089789

http://blog.csdn.net/gao_chun/article/details/46854323

http://blog.csdn.net/fengyud/article/details/6147597

http://blog.csdn.net/kook_okko/article/details/2635294

http://blog.csdn.net/dc15822445347/article/details/8142103

更多相关文章

  1. Android中WebView的缓存
  2. android移动支付——PayPal支付
  3. 解析Glide用法
  4. android与Web服务器交互时的cookie使用-兼谈大众点评数据获得(原
  5. Android开发学习笔记之 Service 的使用
  6. Android应用程序介绍页面实现 (二)
  7. Android(安卓)绘制环形进度图
  8. 苹果App被置病毒 网友:安卓无压力
  9. 利用9-Patch PNG来实现ListView的圆角显示

随机推荐

  1. Android应用程序窗口View的创建过程
  2. 系统编译三方apk,out目录有这个apk,但刷机
  3. Android培训班(12)
  4. Android 4.4 以太网网络共享功能研究和实
  5. Android传感器编程实例开发——三轴数据
  6. 移动开发 - Android - 实现两个页面(Acti
  7. 【攻克Android (2)】Android各版本、app
  8. android 学习(第一篇:环境搭建和helloworld
  9. Android聊天软件开发(基于网易云IM即时通
  10. Android中使用菜单