Exifinterface obtains GPS Data

Source: Internet
Author: User
Tags id3 tag

Get the GPS code:


Exifinterface Ei = new exifinterface (environment. getexternalstoragedirectory (). getpath () + "/3.jpg ");
Log. W ("test", "tag_gps_latitude =" + ei. getattributedouble (Ei. tag_gps_latitude, 0.0 ));
Log. W ("test", "tag_gps_long1_=" + ei. getattribute (Ei. tag_gps_long1 ));

Print result:

12-30 08:01:46. 127: Warn/test (4857): tag_gps_latitude = 22/1, 32/1, 1691/100
12-30 08:01:46. 127: Warn/test (4857): tag_gps_long1_= 113/1, 56/1, 2468/100

 

View Details on Windows:

Dimension: 22; 32; 16.91
Longitude: 113; 56; 24.68

 

Aha, accidentally let me know where I am. Don't drop bombs in this place.

Latitude and longitude format: degree; minute; second

The formula for converting longitude and latitude to double: (second/60 + minutes)/60 + degrees

 

Additional information:

It168 Technology] The exifinterface class has been added since Android 2.0. The exifinterface class mainly describes some additional information about multimedia files, such as JPG images, such as the photo device manufacturer, the date and time at that time, and the exposure time, shutter speed. This class is located in the location of Android. Media. exifinterface. You must call the API level at least 5, that is, the 2.0 SDK.

1. The exifinterface class provides us with a practical method: Public byte [] getthumbnail (). This method can generate a thumbnail and return a byte array, we used outputstream to save it as a JPG file. Of course, if a drawable object is displayed, you can use the decodebytearray (byte [], Int, INT) class to parse the byte array. However, the generated Resolution is unclear.

  2. Mime EXIF information of the image

The EXIF information of the image is similar to the ID3 tag of MP3, and the storage of attributes and values is used. Public void setattribute (string tag, string value) is used to set the attribute. You can use public int getattributeint (string tag, int defaultvalue) and Public String getattribute (string tag) to obtain the attribute) both methods can be used. The second parameter of the getattributeint overload method is the default value we set. If the value is successful, the value of the corresponding tag is returned. The specific integer content is the direct return value of the method. In method 2, the method returns the result directly. If the result fails, the return value is null.

Currently, the android SDK defines the following tags:

Tag_datetime time and date

Tag_flash flashlight

Tag_gps_latitude

Tag_gps_latitude_ref latitude reference

Tag_gps_long1_longitude

Tag_gps_longitude_ref longitude reference

Tag_image_length: Image Length

Tag_image_width: Image Width

Tag_make device manufacturer

Tag_model Device Model

Tag_orientation direction

Tag_white_balance White Balance

From the android 2.0.1 SDK, there are not many attributes. Details may be added in later versions. The call example is as follows:

String sfilename = "cwj-android123.jpg ";

Exifinterface EXIF = new exifinterface (filename );

String smodel = EXIF. getattribute (exifinterface. tag_model );

The final smodel is the model of the photo device. here we can see that it is a Nexus One or HTC hero character. Of course, it is a digital camera that uploads the original file generated from the PC, for example, ixus 980.

 

 

 

Http://doc.chinaunix.net/android/200910/488798.shtml

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.