我做了一个安卓应用程序。在我的应用中,我要截取一个图片并把它发送到服务器上。在某种设备里,截取的图片上传到服务器上的时候会旋转90度。代码如下:
Uri selectedImage = data.getData();
File imageFile = new File(selectedImage.toString());
ExifInterface exif;
try {
exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotate=90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate=180;
break;
}
但是很不幸,在每个设备里我得到的orientation的值都是0,甚至图片旋转90度的那个设备上也是一样的结果。