地理标记的机器人 [英] geo tagging in android

查看:180
本文介绍了地理标记的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道地理标记是否已启用或Android摄像头通过code设置禁用? 我们正在安装的地理标记照片通过code。我们使用位置管理,位置监听器获得的纬度和经度和保存使用的Exif接口,该坐标照片。

How to know whether the geo tagging is enabled or disabled in android camera setting through the code? We are attaching the geo tags to photos through code. We using Location Manager,Location Listener to get the latitude and longitude and save this coordinates to photo using Exif interface.

ExifInterface exif = new ExifInterface(/sdcard/photo/photoname.jpg);
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE,String.valueOf(latitudeValueInDecimal));
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,String.valueOf(longitudeValueInDecimal));
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF,"N");
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF,"W");
exif.saveAttributes();

我们必须只有当地理标记在照相机设置被启用GPS坐标(纬度和经度)添加到照片所以如何在相机设置检查地理标记(存储位置)的状态?我使用的HTC野火S的电话?

We have to add gps coordinates(latitude and longitude) to photo only when the geotag is enabled in camera setting? so how to check the status of geo tag(store location) in camera settings? I am using HTC wildfire S phone?

推荐答案

您无法查询此编程。你必须手动读取拍摄的照片的标签和检查GPS坐标,如果标记为空,然后地理标记是禁用的。

You can't check this programatically. You'll have to read the tags of the pictures taken and check the GPS-coordinates manually, if the tags are empty then geo-tagging is disabled.

您可以使用ExifInterface类来读取JPEG图像的EXIF元数据。下面是官方文档的链接解释的:

You can use the ExifInterface class to read the EXIF metadata from JPEG images. Here's the official docs link explaining this:

http://developer.android.com/reference/android/media/ ExifInterface.html

下面的示例code,你可以用它来读取标签:

Here's sample code you can use to read the tags:

Bundle bundle = getIntent().getExtras();

if (null != bundle) {
    String filepath = bundle.getString(FILE_PATH_KEY);

    try {
        ExifInterface exif = new ExifInterface(filepath);
        StringBuilder builder = new StringBuilder();

        builder.append("Date & Time: " + getExifTag(exif, ExifInterface.TAG_DATETIME) + "\n\n");
        builder.append("Flash: " + getExifTag(exif, ExifInterface.TAG_FLASH) + "\n");
        builder.append("Focal Length: " + getExifTag(exif, ExifInterface.TAG_FOCAL_LENGTH) + "\n\n");
        builder.append("GPS Datestamp: " + getExifTag(exif, ExifInterface.TAG_FLASH) + "\n");
        builder.append("GPS Latitude: " + getExifTag(exif, ExifInterface.TAG_GPS_LATITUDE) + "\n");
        builder.append("GPS Latitude Ref: " + getExifTag(exif, ExifInterface.TAG_GPS_LATITUDE_REF) + "\n");
        builder.append("GPS Longitude: " + getExifTag(exif, ExifInterface.TAG_GPS_LONGITUDE) + "\n");
        builder.append("GPS Longitude Ref: " + getExifTag(exif, ExifInterface.TAG_GPS_LONGITUDE_REF) + "\n");
        builder.append("GPS Processing Method: " + getExifTag(exif, ExifInterface.TAG_GPS_PROCESSING_METHOD) + "\n");
        builder.append("GPS Timestamp: " + getExifTag(exif, ExifInterface.TAG_GPS_TIMESTAMP) + "\n\n");
        builder.append("Image Length: " + getExifTag(exif, ExifInterface.TAG_IMAGE_LENGTH) + "\n");
        builder.append("Image Width: " + getExifTag(exif, ExifInterface.TAG_IMAGE_WIDTH) + "\n\n");
        builder.append("Camera Make: " + getExifTag(exif, ExifInterface.TAG_MAKE) + "\n");
        builder.append("Camera Model: " + getExifTag(exif, ExifInterface.TAG_MODEL) + "\n");
        builder.append("Camera Orientation: " + getExifTag(exif, ExifInterface.TAG_ORIENTATION) + "\n");
        builder.append("Camera White Balance: " + getExifTag(exif, ExifInterface.TAG_WHITE_BALANCE) + "\n");

        builder = null;
    } catch (IOException e) {
        e.printStackTrace();
    }
}

这篇关于地理标记的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆