private int getRotation(Uri image) { InputStream is = null; try { is = mXmppConnectionService.getContentResolver().openInputStream(image); return ExifHelper.getOrientation(is); } catch (FileNotFoundException e) { return 0; } finally { close(is); } }