ExifInterface only ads Speed Ref but not value itself

45 Views Asked by At

I tried the following code:

exif.setAttribute(
    ExifInterface.TAG_GPS_SPEED,
    "50"
)
exif.setAttribute(
    ExifInterface.TAG_GPS_SPEED_REF,
    ExifInterface.GPS_SPEED_KILOMETERS_PER_HOUR
)

Metadata Exif:

[GPS]
Speed Ref                     : K

No value. What's wrong here?

Updated

I tried to use ExifInterface.setGpsInfo(Location)

val exif = ExifInterface(parcelFileDescriptor.fileDescriptor)
exif.setGpsInfo(location)
exif.saveAttributes()
parcelFileDescriptor.close()

It has the following code for setting speed inside the method:

setAttribute(TAG_GPS_SPEED_REF, "K");
setAttribute(TAG_GPS_SPEED, new Rational(location.getSpeed()
        * TimeUnit.HOURS.toSeconds(1) / 1000).toString());

But still there is no speed, only REF, but all other data is set normally (coordinates and altitude, though the last one was saved as 0) and I checked that location.speed was not 0:

[GPS]
Latitude                      : PRIVATE
Altitude                      : 0.00
Latitude Ref                  : North
Processing Method             : fused
Altitude Ref                  : Above Sea Level
Speed Ref                     : K
Longitude Ref                 : East
TimeStamp                     : 18 43 58
Longitude                     : PRIVATE
Date Stamp                    : 2023:12:18
0

There are 0 best solutions below