所有ExifInterface值都返回0或null

时间:2017-02-21 13:09:34

标签: android exif

我试图获取图像的gps位置,但我得到的只是null / 0,我试图从不同的图像中获取其他exif信息,但结果仍为null / 0

public void MarkGeoTagImage(String imagePath)
{
    try {
        ExifInterface exif = new ExifInterface(imagePath);
Toast.makeText(MainActivity.this, imagePath, Toast.LENGTH_LONG).show();
        Toast.makeText(MainActivity.this, exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE),Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

第一个toast显示图像的绝对路径,如/storage/sdcard0/etp_images/test.jpg,但第二个toast仅显示0或null作为结果。

2 个答案:

答案 0 :(得分:2)

可能它不是解决方案,但我之前遇到过ExifInterface的问题。原始类ExifInterface有不同的错误。尝试使用此类的支持版本。就我而言,它解决了我的问题。 使用Gradle进行编译:{{1​​}}

答案 1 :(得分:1)

我遇到了同样的问题,所以我还将ExifInterface支持库添加到我的项目中,具有以下依赖关系:

Info (11667) / BrixnMobileUIiOS: Found new TLS offset at 224
Error (11667) / BrixnMobileUIiOS(UIKit): The app delegate must implement the window property if it wants to use a main storyboard file.
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Mac' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Mac' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Deprecated' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Deprecated' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Mobile' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'Akavache.Mobile' (culture: '')
Info (11667) / BrixnMobileUIiOS: VideoPlayer [INFO]: Initializing Xamarin Forms Video Player on iPhone v10.3.2
Info (11667) / BrixnMobileUIiOS(AppleJPEG): [0x1057e8600] Created session
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'ReactiveUI.XamForms' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'ReactiveUI.XamForms' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'ReactiveUI.Winforms' (culture: '')
Info (11667) / BrixnMobileUIiOS: Xamarin.iOS: Unable to locate assembly 'ReactiveUI.Winforms' (culture: '')
Info (11667) / BrixnMobileUIiOS: [Error] CurrentDomainOnUnhandledException
Info (11667) / BrixnMobileUIiOS: Unhandled managed exception:
Info (11667) / BrixnMobileUIiOS: critical: Stacktrace:
Info (11667) / BrixnMobileUIiOS: critical:
Info (11667) / BrixnMobileUIiOS: critical:  0   BrixnMobileUIiOS                    0x0000000103c0facc WebPGetDecoderVersion + 323252
Info (11667) / BrixnMobileUIiOS: critical:  1   libsystem_platform.dylib            0x000000018cbb131c _sigtramp + 52
Info (11667) / BrixnMobileUIiOS: critical:  2   libsystem_pthread.dylib             0x000000018cbb7264 pthread_kill + 112
Info (11667) / BrixnMobileUIiOS: critical:  3   libsystem_c.dylib                   0x000000018ca619c4 abort + 140
Info (11667) / BrixnMobileUIiOS: critical:  4   BrixnMobileUIiOS                    0x0000000103d46d28 xamarin_get_block_descriptor + 4588
Info (11667) / BrixnMobileUIiOS: critical:  5   BrixnMobileUIiOS                    0x0000000103c557f4 WebPGetDecoderVersion + 609244
Info (11667) / BrixnMobileUIiOS: critical:  6   BrixnMobileUIiOS                    0x0000000103c0f5cc WebPGetDecoderVersion + 321972
Info (11667) / BrixnMobileUIiOS: critical:  7   BrixnMobileUIiOS                    0x0000000103c0e5f0 WebPGetDecoderVersion + 317912
Info (11667) / BrixnMobileUIiOS: critical:  8   BrixnMobileUIiOS                    0x0000000103c06580 WebPGetDecoderVersion + 285032
Info (11667) / BrixnMobileUIiOS: critical:  9   BrixnMobileUIiOS                    0x0000000100775798 sqlite3_db_readonly + 6676600
Info (11667) / BrixnMobileUIiOS: critical:  10  BrixnMobileUIiOS                    0x00000001005103fc sqlite3_db_readonly + 4164828
Info (11667) / BrixnMobileUIiOS: critical:  11  BrixnMobileUIiOS                    0x0000000100513ae4 sqlite3_db_readonly + 4178884
Info (11667) / BrixnMobileUIiOS: critical:  12  BrixnMobileUIiOS                    0x0000000101fef498 sqlite3_db_readonly + 32341368
Info (11667) / BrixnMobileUIiOS: critical:  13  BrixnMobileUIiOS                    0x00000001019da454 sqlite3_db_readonly + 25963828
Info (11667) / BrixnMobileUIiOS: critical:  14  BrixnMobileUIiOS                    0x000000010071bcd4 sqlite3_db_readonly + 6309300
Info (11667) / BrixnMobileUIiOS: critical:  15  BrixnMobileUIiOS                    0x0000000103c1e6a8 WebPGetDecoderVersion + 383632
Info (11667) / BrixnMobileUIiOS: critical:  16  BrixnMobileUIiOS                    0x0000000103c9843c WebPGetDecoderVersion + 882724
Info (11667) / BrixnMobileUIiOS: critical:  17  BrixnMobileUIiOS                    0x0000000103c98398 WebPGetDecoderVersion + 882560
Info (11667) / BrixnMobileUIiOS: critical:  18  BrixnMobileUIiOS                    0x0000000103b33be4 sqlite3_db_readonly + 60933316
Info (11667) / BrixnMobileUIiOS: critical:  19  BrixnMobileUIiOS                    0x0000000103b3aa3c sqlite3_db_readonly + 60961564
Info (11667) / BrixnMobileUIiOS: critical:  20  Foundation                          0x000000018e5e64cc <redacted> + 340
Info (11667) / BrixnMobileUIiOS: critical:  21  CoreFoundation                      0x000000018daa142c <redacted> + 24
Info (11667) / BrixnMobileUIiOS: critical:  22  CoreFoundation                      0x000000018daa0d04 <redacted> + 388
Info (11667) / BrixnMobileUIiOS: critical:  23  CoreFoundation                      0x000000018da9e9a8 <redacted> + 744
Info (11667) / BrixnMobileUIiOS: critical:  24  CoreFoundation                      0x000000018d9ceda4 CFRunLoopRunSpecific + 424
Info (11667) / BrixnMobileUIiOS: critical:  25  GraphicsServices                    0x000000018f438074 GSEventRunModal + 100
Info (11667) / BrixnMobileUIiOS: critical:  26  UIKit                               0x0000000193c89058 UIApplicationMain + 208
Info (11667) / BrixnMobileUIiOS: critical:  27  BrixnMobileUIiOS                    0x0000000102270f64 sqlite3_db_readonly + 34969668
Info (11667) / BrixnMobileUIiOS: critical:  28  BrixnMobileUIiOS                    0x0000000101bbbfcc sqlite3_db_readonly + 27936940
Info (11667) / BrixnMobileUIiOS: critical:  29  BrixnMobileUIiOS                    0x0000000101bbbe8c sqlite3_db_readonly + 27936620
Info (11667) / BrixnMobileUIiOS: critical:  30  BrixnMobileUIiOS                    0x00000001001ff554 sqlite3_db_readonly + 949812
Info (11667) / BrixnMobileUIiOS: critical:  31  BrixnMobileUIiOS                    0x000000010071bcd4 sqlite3_db_readonly + 6309300
Info (11667) / BrixnMobileUIiOS: critical:  32  BrixnMobileUIiOS                    0x0000000103c1e6a8 WebPGetDecoderVersion + 383632
Info (11667) / BrixnMobileUIiOS: critical:  33  BrixnMobileUIiOS                    0x0000000103c9843c WebPGetDecoderVersion + 882724
Info (11667) / BrixnMobileUIiOS: critical:  34  BrixnMobileUIiOS                    0x0000000103c9b660 WebPGetDecoderVersion + 895560
Info (11667) / BrixnMobileUIiOS: critical:  35  BrixnMobileUIiOS                    0x0000000103c02f04 WebPGetDecoderVersion + 271084
Info (11667) / BrixnMobileUIiOS: critical:  36  BrixnMobileUIiOS                    0x0000000103d4b8f0 xamarin_localized_string_format_9 + 3196
Info (11667) / BrixnMobileUIiOS: critical:  37  BrixnMobileUIiOS                    0x0000000103bbc530 sqlite3_db_readonly + 61492752
Info (11667) / BrixnMobileUIiOS: critical:  38  libdyld.dylib                       0x000000018c9dd59c <redacted> + 4

并且还编写了以下方法以获得图像方向角度:

compile 'com.android.support:exifinterface:25.1.0'