相关疑难解决方法(0)

Android将EXIF GPS纬度和经度写入JPEG失败

我想在jpeg照片中添加经度和纬度等GPS数据.通过标签卡(NFC)捕获照片在logcat中可以显示正确的值,但这些值不能写入jpg照片文件!

下面是我的代码:它用于获取保存的jpg文件并调用下面的方法该方法用于将EXIF GPS参数添加到jpg中经度和纬度等GPS参数已经在另一个活动中使用.

我在Firefox中使用EXIF Viewer来查看结果.

IO异常的位置是否重要?

以下是可能导致失败的重要日志cat日志:07-26 11:48:30.386:D/NativeNfcTag(195):标记丢失,重新启动轮询循环

 public static void writeFile (File photo, double latitude, double longitude) throws IOException{


    ExifInterface exif = null;

    try{
        Log.v("latiDouble", ""+latitude);
        Log.v("longiDouble", ""+longitude);
        exif = new ExifInterface(photo.getCanonicalPath());
        if (exif != null) {
        double latitu = latitude;
        double longitu = longitude;
        double alat = Math.abs(latitu);
        double along = Math.abs(longitu);
        String stringLati = convertDoubleIntoDegree(alat);
        String stringLongi = convertDoubleIntoDegree(along);
        exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, stringLati);            
        exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, stringLongi);
        Log.v("latiString", ""+ stringLati);
        Log.v("longiString", ""+ stringLongi);
        exif.saveAttributes();
        String lati = exif.getAttribute (ExifInterface.TAG_GPS_LATITUDE);  
         String longi …
Run Code Online (Sandbox Code Playgroud)

gps android jpeg location exif

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

exif ×1

gps ×1

jpeg ×1

location ×1