//사진보내기
public void sendimage(View view) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUST_IMAGE_GET);
}
private String getRealPathFromURI(Uri contentUri) {
int column_index=0;
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
if(cursor.moveToFirst()){
column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
}
return cursor.getString(column_index);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == REQUST_IMAGE_GET && resultCode == RESULT_OK && data != null) {
Uri fullPhotoUri = data.getData();
assert fullPhotoUri != null;
String fullstring = fullPhotoUri.toString();
String realpath=getRealPathFromURI(fullPhotoUri);
ExifInterface exif = null;
try {
exif = new ExifInterface(realpath);
} catch (IOException e) {
e.printStackTrace();
}
assert exif != null;
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
.....................
마지막줄 exiforientation에서 밑에 에러발생합니다
error: Attempt to invoke virtual method 'int android.media.ExifInterface.getAttributeInt(java.lang.String, int)' on a null object reference
minsdk19
targetsdk28
어떻게하면 좋을까요 고수님들 ㅠㅠ
+exif 로그로 확인했더니 nullorientation나왔는데 null이 나왔단거겠죠?