【问题标题】:android - how to know geotagging feature from camera is on or no?android - 如何知道相机的地理标记功能是否开启?
【发布时间】:2016-11-28 03:05:37
【问题描述】:

如何知道相机的地理标记功能是否开启?

打开拍照手机的代码

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);


        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        // start the image capture Intent
        startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);

【问题讨论】:

标签: android android-camera geotagging


【解决方案1】:

您无法以编程方式检查此内容。您必须阅读所拍照片的标签并手动检查 GPS 坐标,如果标签为空,则禁用地理标记。

您可以使用 ExifInterface 类从 JPEG 图像中读取 EXIF 元数据。这是解释这一点的官方文档链接:

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

这里是您可以用来读取标签的示例代码:

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();
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-22
    • 2018-05-10
    • 2023-03-18
    • 2013-10-03
    • 1970-01-01
    相关资源
    最近更新 更多