2014-03-13 22 views
1

我用這個代碼,以獲取有關SD卡圖像信息的位置,ExifInterface拿到照片

 File file = (File) iterator.next(); 
      ExifInterface exif = new ExifInterface(file.getAbsolutePath()); 

      String Date_Time = getExifTag(exif, ExifInterface.TAG_DATETIME); 
      String Flash = getExifTag(exif, ExifInterface.TAG_FLASH); 
      String Focal_Length = getExifTag(exif, ExifInterface.TAG_FOCAL_LENGTH) ; 

      String GPS_Datestamp = getExifTag(exif, ExifInterface.TAG_FLASH); 
      String GPS_Latitude = getExifTag(exif, ExifInterface.TAG_GPS_LATITUDE); 
      String GPS_Latitude_Ref = getExifTag(exif, ExifInterface.TAG_GPS_LATITUDE_REF); 
      String GPS_Longitude = getExifTag(exif, ExifInterface.TAG_GPS_LONGITUDE); 
      String GPS_Longitude_Ref = getExifTag(exif, ExifInterface.TAG_GPS_LONGITUDE_REF); 
      String GPS_Processing_Method = getExifTag(exif, ExifInterface.TAG_GPS_PROCESSING_METHOD); 
      String GPS_Timestamp = getExifTag(exif, ExifInterface.TAG_GPS_TIMESTAMP) ; 

      String Image_Length = getExifTag(exif, ExifInterface.TAG_IMAGE_LENGTH); 
      String Image_Width = getExifTag(exif, ExifInterface.TAG_IMAGE_WIDTH) ; 

      String Camera_Make = getExifTag(exif, ExifInterface.TAG_MAKE); 
      String Camera_Model = getExifTag(exif, ExifInterface.TAG_MODEL); 
      String Camera_Orientation = getExifTag(exif, ExifInterface.TAG_ORIENTATION); 
      String Camera_White_Balance = getExifTag(exif, ExifInterface.TAG_WHITE_BALANCE); 

但GPS_Longitude,GPS_Latitude返回null?

當位置服務ON時,我捕獲了新照片,但仍返回null。

+0

它顯示在畫廊應用程序內的文件屬性? –

+0

不,大部分物品成立,但GPS位置我沒有找到它。 –

回答

1

我解決我的問題,如果我們想顯示照片的位置是被捕獲, 您捕捉任何影像之前,我們必須使攝像頭設置「GPS TAG」,

進入相機>>設置>> GPS標籤>>從關閉切換到開啓。

然後上面的代碼完全工作。

+0

嘿,我只是使用你的代碼爲我自己的應用程序。我收到錯誤消息「方法getExifTag(ExifInterface,String)未定義類型Get_Pic」。 Get_Pic是我的活動類。任何想法,爲什麼我得到這個錯誤? – DrkStr

+0

對不起,遲到重播你,這種方法添加到您的代碼, \t私人字符串getExifTag(ExifInterface EXIF,字符串標記) \t { \t \t字符串屬性= exif.getAttribute(標籤); \t \t return(null!= attribute?attribute:「」); \t} –