http://programmar.tistory.com/5 여기 사이트에서 이미지를 크롭하고 크롭한 이미지의 Uri를 가지고
(사이트에서는 photoUri를 가지고 비트맵으로 변환했지만 저는 그냥 이미지뷰.setImageUri(photoUri)로 썼습니다.)
이미지의 제목과 주소를 가지고 php를 통해 서버에 업로드를 할려고하는데 크롭 하지 않은 이미지의 이름과 주소는 잘 받아져서 서버에 업로드가 되는데 크롭한 이미지들 에러가 떠서 디버그를 해봣는데
public static String getImageNameToUri(Context context,Uri data, int type){
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(data, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
여기서 진하게 칠해진 곳에서 에러가 뜨더군요....
에러는
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { dat=content://com.example.kmw.newspaper.provider/storage/emulated/DCIM/Camera/Pro_20180814_173857_438471684.jpg launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }} to activity {com.example.kmw.newspaper/com.example.kmw.newspaper.ChPicture}: java.lang.IllegalArgumentException: column '_data' does not exist
이렇게 뜹니다. 기존의 이미지들은 잘 되는데 크롭한것만 안됩니다.
예시
기존이미지:content://media/external/images/media/44557
크롭한이미지:content://com.example.kmw.newspaper.provider/storage/emulated/DCIM/Camera/Pro_20180814_173857_438471684.jpg