Exif文件找不到经度和经度android

时间:2016-07-12 15:50:33

标签: android

我已经尝试在我的内部存储上找到我的照片的协调,但是当我在我的文本字段中启动我的应用程序时,没有返回latidude或经度但是如果我选择了witdht或height有返回。 有我的代码

public class MainActivity extends Activity {

private ImageView imageView;
DBOpenHelper doh = new DBOpenHelper(this);
private TextView textFieldLat;
private TextView textFieldLong;
String imagefile ="/storage/emulated/0/DCIM/Camera/IMG_20160712_172931.jpg";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    this.imageView = (ImageView) findViewById(R.id.imageView);
    final Button takePhoto = (Button) findViewById(R.id.takePhoto);

    textFieldLat = (TextView) findViewById(R.id.textFieldLat);
    textFieldLong = (TextView) findViewById(R.id.textFieldLong);

    textFieldLat.setText(ReadExifLat(imagefile));
    textFieldLong.setText(ReadExifLong(imagefile));
}

String ReadExifLat(String file){
    String exif=file;
    try {
        ExifInterface exifInterface = new ExifInterface(file);
        exif = exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return exif;
}

String ReadExifLong(String file){
    String exif=file;
    try {
        ExifInterface exifInterface = new ExifInterface(file);
        exif = exifInterface.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return exif;
}
}

如果我用TAG_GPS_WIDTH替换TAG_GPS_LATITUDE就行了。 我的设备中的照片有坐标。 谢谢

0 个答案:

没有答案