Android 获取图片exif信息
2024-10-18 18:29:05
使用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
最新文章
- RPC 的概念模型与实现解析
- which type of VS files should be committed into a version control system
- 【C#进阶系列】12 泛型
- [转]初探 PhoneGap 框架在 Android 上的表现
- async 和await
- 使用ffmpeg向crtmpserver发布rtsp流
- php静态属性和静态方法
- Mirantis MCP 1.0:OpenStack 和 Kubernetes 整合的第一步
- CentOS7.4+OpenStack-Queens版本部署
- 区块链教程(二):比特币、区块链、以太坊、Hyperledger的关系
- iOS 之 HTTPS集成实战应用
- GDAL中文件的驱动及对应的文件格式(转) https://blog.csdn.net/haojknm/article/details/5851968
- C/S,B/S的区别与联系
- 二叉堆复习(包括d堆)
- 将页面中表格数据导出excel格式的文件(vue)
- 9g10在nandflash扇区的分配地址
- python WEB UI自动化在日期框中动态输入当前日期
- Intel微处理器学习笔记(二) 三种模式
- 关于C和C++
- Codeforces 86C Genetic engineering (AC自己主动机+dp)
热门文章
- [C/C++]函数指针和函数分发表
- ES6 Features系列:Template Strings &; Tagged Template Strings
- C#正则表达式教程和示例
- MVC之前的那点事儿系列(2):HttpRuntime详解分析(上)
- 使用DocX开源组件,实现动态数据的填充。
- MyEclipse10修改servlet模版
- 修复 XE8 for Android 方向传感器 headingX,Y,Z 不会动的问题
- 阿里前端框架Alice是个不错的选择
- java 本地目录文件删除 ***最爱那水货
- Hibernate原生SQL查询