안드로이드 스튜디오 갤러리에서 이미지 가져오기 오류
조회수 6085회
갤러리에서 이미지를 가지고와서 이미지뷰에 띄우려고 합니다.
하지만 빌드를 했을때 갤러리에 들어가서 이미지를 누르는 것까지는 잘 되는데 누르고 앱으로 돌아왔을때 이미지뷰에는 아무런 변화가 안생기네요.
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/download/NISI20161203_0012458513_web_99_20161203211603.jpg (Permission denied)
이 두가지가 무엇을 의미하는지 궁금하고 해결방법은 무엇인지 궁금합니다. 자세한 답변 부탁드릴게요.
아래는 소스코드 입니다.
public class ReviewActivity extends AppCompatActivity {
private static final int GALLERY_CODE = 1;
public ImageView iv_receipt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_review);
}
public void onClick(View v) {
if (v.getId() == R.id.button) {
SelectGallery();
}
}
private void SelectGallery() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case GALLERY_CODE:
SendPicture(data); //갤러리에서 가져오기
break;
default:
break;
}
}
}
private void SendPicture(Intent data) {
String imagePath = getRealPathFromURI(data.getData()); // path 경로
/*ExifInterface exif = null;
try {
exif = new ExifInterface(imagePath);
} catch (IOException e) {
e.printStackTrace();
}*/
//int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
//int exifDegree = exifOrientationToDegrees(exifOrientation);
iv_receipt = (ImageView)findViewById(R.id.imageView3);
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);//경로를 통해 비트맵으로 전환
iv_receipt.setImageBitmap(bitmap);//이미지 뷰에 비트맵 넣기
}
public String getRealPathFromURI(Uri contentUri) {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
/*
public int exifOrientationToDegrees(int exifOrientation) {
if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
return 90;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
return 180;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
return 270;
}
return 0;
}
public Bitmap rotate(Bitmap src, float degree) {
// Matrix 객체 생성
Matrix matrix = new Matrix();
// 회전 각도 셋팅
matrix.postRotate(degree);
// 이미지와 Matrix 를 셋팅해서 Bitmap 객체 생성
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}
*/
}
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력