mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Successfully displayed latitude of image
TODO: Tidy up code and put in coordinate conversion method
This commit is contained in:
parent
ba5fb3bb55
commit
c5fd006dd5
1 changed files with 31 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import android.media.ExifInterface;
|
|||
import android.os.*;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import android.net.*;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
|
@ -42,6 +43,7 @@ public class ShareActivity
|
|||
private String mimeType;
|
||||
private String mediaUriString;
|
||||
private String mediaUriPath;
|
||||
private String mediaUriAbsPath;
|
||||
|
||||
private static final String TAG = "Image";
|
||||
|
||||
|
|
@ -188,10 +190,37 @@ public class ShareActivity
|
|||
Log.d(TAG, "Uri: " + mediaUriString);
|
||||
|
||||
mediaUriPath = mediaUri.getPath();
|
||||
Log.d(TAG, "Path: " + mediaUriPath);
|
||||
|
||||
// Will return "image:x*"
|
||||
String wholeID = DocumentsContract.getDocumentId(mediaUri);
|
||||
|
||||
// Split at colon, use second item in the array
|
||||
String id = wholeID.split(":")[1];
|
||||
|
||||
String[] column = { MediaStore.Images.Media.DATA };
|
||||
|
||||
// where id is equal to
|
||||
String sel = MediaStore.Images.Media._ID + "=?";
|
||||
|
||||
Cursor cursor = getContentResolver().
|
||||
query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
column, sel, new String[]{ id }, null);
|
||||
|
||||
String filePath = "";
|
||||
|
||||
int columnIndex = cursor.getColumnIndex(column[0]);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
filePath = cursor.getString(columnIndex);
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
|
||||
Log.d(TAG, "Path 1: " + mediaUriPath);
|
||||
Log.d(TAG, "Path 2: " + filePath);
|
||||
|
||||
try {
|
||||
exif = new ExifInterface(mediaUriPath);
|
||||
exif = new ExifInterface(filePath);
|
||||
String latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
|
||||
Log.d("Image", "Latitude: " + latitude);
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue