使用android api读取图片的exif信息

布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="read"
android:text="读取exif信息" /> </LinearLayout>

代码如下:

package com.wuyudong.loadimage;

import java.io.IOException;

import android.app.Activity;
import android.media.ExifInterface;
import android.os.Bundle;
import android.view.View; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); } public void read(View view) {
try {
ExifInterface exif = new ExifInterface("/sdcard/a.jpg");
String time = exif.getAttribute(ExifInterface.TAG_DATETIME);
System.out.println(time); String model = exif.getAttribute(ExifInterface.TAG_MODEL);
System.out.println("model:" + model); } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
}

运行项目,打印如下结果:

09-04 07:51:32.561: I/System.out(11278): 2014:09:06 12:34:25
09-04 07:51:32.561: I/System.out(11278): model:GT-I8558

最新文章

  1. RPC 的概念模型与实现解析
  2. which type of VS files should be committed into a version control system
  3. 【C#进阶系列】12 泛型
  4. [转]初探 PhoneGap 框架在 Android 上的表现
  5. async 和await
  6. 使用ffmpeg向crtmpserver发布rtsp流
  7. php静态属性和静态方法
  8. Mirantis MCP 1.0:OpenStack 和 Kubernetes 整合的第一步
  9. CentOS7.4+OpenStack-Queens版本部署
  10. 区块链教程(二):比特币、区块链、以太坊、Hyperledger的关系
  11. iOS 之 HTTPS集成实战应用
  12. GDAL中文件的驱动及对应的文件格式(转) https://blog.csdn.net/haojknm/article/details/5851968
  13. C/S,B/S的区别与联系
  14. 二叉堆复习(包括d堆)
  15. 将页面中表格数据导出excel格式的文件(vue)
  16. 9g10在nandflash扇区的分配地址
  17. python WEB UI自动化在日期框中动态输入当前日期
  18. Intel微处理器学习笔记(二) 三种模式
  19. 关于C和C++
  20. Codeforces 86C Genetic engineering (AC自己主动机+dp)

热门文章

  1. [C/C++]函数指针和函数分发表
  2. ES6 Features系列:Template Strings &amp; Tagged Template Strings
  3. C#正则表达式教程和示例
  4. MVC之前的那点事儿系列(2):HttpRuntime详解分析(上)
  5. 使用DocX开源组件,实现动态数据的填充。
  6. MyEclipse10修改servlet模版
  7. 修复 XE8 for Android 方向传感器 headingX,Y,Z 不会动的问题
  8. 阿里前端框架Alice是个不错的选择
  9. java 本地目录文件删除 ***最爱那水货
  10. Hibernate原生SQL查询