¿Cómo obtener la latititud y la longitud de una imagen en sdcard a mi aplicación?

De mi aplicación puedo abrir la galería. ¿Hay alguna manera de conseguir la latitud y la longitud de cualquier imagen seleccionada en galería a mi aplicación. Cualquier idea me ayuda por favor. Gracias por adelantado

Debe ir con la clase ExifInterface para leer varios metadatos EXIF ​​de Imágenes:

Ejemplo:

ExifInterface exif = new ExifInterface(filepath); exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF); 

Editado:

Ahora aquí obtendrá lat-largo como formato Abajo.

Lat = 30 / 1,12 / 1,34 / 1, largo = 81 / 1,22 / 1,41 / 1

Para convertir esto en valores reales este blog me ayudó.

Tenemos que hacer la conversión de grado, minuto, segundo formulario a forma de GeoPoint.

Por debajo de la manera usted puede hacerlo.

  String LATITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); String LATITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); String LONGITUDE = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); String LONGITUDE_REF = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF); // your Final lat Long Values Float Latitude, Longitude; if((LATITUDE !=null) && (LATITUDE_REF !=null) && (LONGITUDE != null) && (LONGITUDE_REF !=null)) { if(LATITUDE_REF.equals("N")){ Latitude = convertToDegree(LATITUDE); } else{ Latitude = 0 - convertToDegree(LATITUDE); } if(LONGITUDE_REF.equals("E")){ Longitude = convertToDegree(LONGITUDE); } else{ Longitude = 0 - convertToDegree(LONGITUDE); } } private Float convertToDegree(String stringDMS){ Float result = null; String[] DMS = stringDMS.split(",", 3); String[] stringD = DMS[0].split("/", 2); Double D0 = new Double(stringD[0]); Double D1 = new Double(stringD[1]); Double FloatD = D0/D1; String[] stringM = DMS[1].split("/", 2); Double M0 = new Double(stringM[0]); Double M1 = new Double(stringM[1]); Double FloatM = M0/M1; String[] stringS = DMS[2].split("/", 2); Double S0 = new Double(stringS[0]); Double S1 = new Double(stringS[1]); Double FloatS = S0/S1; result = new Float(FloatD + (FloatM/60) + (FloatS/3600)); return result; }; @Override public String toString() { // TODO Auto-generated method stub return (String.valueOf(Latitude) + ", " + String.valueOf(Longitude)); } public int getLatitudeE6(){ return (int)(Latitude*1000000); } public int getLongitudeE6(){ return (int)(Longitude*1000000); } 

Puede utilizar una función "buildin":

 ExifInterface exif = new ExifInterface(path); float[] latLong = new float[2]; boolean hasLatLong = exif.getLatLong(latLong) if (hasLatLong) { System.out.println("Latitude: " + latLong[0]); System.out.println("Longitude: " + latLong[1]); } 

Tal vez sea algo nuevo, pero creo que es mucho más conveniente que la respuesta aceptada.

  • ¿Por qué el servicio de aplicaciones se reinicia y no puede reiniciarlo?
  • Longitud y latitud GPSTracker Android siempre devuelven 0,0
  • La aplicación de ejemplo Android Geofencing sólo funciona si otra aplicación está abierta mediante GPS
  • Frecuencia de actualización de Android GPS
  • Cómo falsificar la ubicación para hacer pruebas con LocationClient y Geofences en Android?
  • Android - No se puede obtener la ubicación del GPS en el emulador
  • ¿Cuánto tiempo hace que se registró la última ubicación conocida?
  • El proveedor de red genera 2 copias de una ubicación
  • Android GPS tarda un tiempo en ser preciso
  • Android Habilitar y deshabilitar GPS
  • Realidad Aumentada - Utilizando sólo GPS
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.