Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geo tagging in android

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

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?

like image 552
Praveen Avatar asked Oct 05 '12 06:10

Praveen


People also ask

What is geo tagging on phone?

Geotagging is the act of including geographical information about where a photo was taken in with the digital photo file. Geotagging is extremely helpful to anyone who takes a large number of pictures and needs a way to record exactly where each photo was taken.

What is geo tagging and how it works?

Geotagging is a process of assigning a 'geo-tag' or adding some 'geographical information' in various 'media' forms such as a digital photograph, video or even in a SMS message.

What is geo tagging?

Geotagging is the process of appending geographic coordinates to media based on the location of a mobile device. Geotags can be applied to photos, videos, websites, text messages, and QR codes, and could also include time stamps or other contextual information.

How do I turn on geotag?

Android. On most Android phones, you can turn geotagging off by doing the following: start camera application – tap the settings button – find the gps tagging option and turn it off.


1 Answers

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.

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

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();
    }
}
like image 176
Anup Cowkur Avatar answered Oct 12 '22 23:10

Anup Cowkur