1

I'm trying read the location from images which is taken from the camera api which I included in my project.

But

exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)

gives null.

I know I need to enable save location(geo tagging) in settings. But I don't like to do that, as I need it to be done programmatically.

Is it possible to enable or disable geo tagging?

Cœur
  • 37,241
  • 25
  • 195
  • 267
shiv
  • 165
  • 11
  • 1
    Thankfully no because that would be a huge privacy issue – tyczj Feb 13 '20 at 14:30
  • @tyczj Then how to do it please tell me. I mean some alternative way to add lat long time to a image. – shiv Feb 13 '20 at 14:31
  • 1
    You dont, its up to the user to enable it not you – tyczj Feb 13 '20 at 14:31
  • @tyczj i have a requirement to force my users. But they are very uneducated people they don't know how to enable it. and scolding me, the developer of the app for not saving location. – shiv Feb 13 '20 at 14:34
  • @tyczj So, kindly suggest me any alternative way in order to capture location and time. – shiv Feb 13 '20 at 14:36
  • 1
    Well you need to somehow explain that it cant be done because of privacy reasons and is unreasonable for anyone to expect that and for you to get yelled at about. The only thing you can do really is manually get a location from the location manager when you take a picture but that is assuming you are using the intent to launch the camera and also the users can deny the permission to get the location – tyczj Feb 13 '20 at 14:40
  • @tyczj i enabled geotagging on default camera, and took image from my custom camera. and i'm not getting location details. can you help me on this. – shiv Feb 13 '20 at 14:44
  • @tyczj Android 12, Blackview A85: camera requires geolocation, otherwise won't open. – Andry Jan 10 '23 at 11:04

1 Answers1

0

GPS information is not directly related to Android Camera API. The way geo tagging works is:

  • Android Camera App gets Geo Location permissions and before the capture gets the coordinates (lat, long) and either give it to camera 2 api to be added in exif of final jpeg (if using JPEG) or encode it itself into final jpeg.

Assuming you have an app that invokes camera api to capture image, what you could do is:

  • Have geo permissions in your app.
  • Invoke camera api for capturing image.
  • Once the image is returned, get coordinates from geo location APIs.

Use it the way you wish to.

Minhaz
  • 937
  • 1
  • 10
  • 25
  • anyhow i ended up by storing location details in server itself. – shiv Feb 17 '20 at 05:42
  • How do you figure that out? using the ip address? – Minhaz Feb 17 '20 at 06:35
  • nope I'm already using google maps. So i have location access permission. Now for geo tagging it asked to enable somewhere in setting. So instead of geotagging to image i store the details on server. – shiv Feb 17 '20 at 07:24