안드로이드 초보자입니다.ㅠㅠ앱만드는 과정중에서 카메라로 찍어서 이미지뷰에 띄어 확인하는것을 만드는데 카메라 실행중(기본앱카메라) 백버튼하면 오류가 뜹니다. 찾아서 해봐도 해결하기 힘드네요 고수님들 조언좀 부탁드립니다ㅠㅠㅠ
우선로고
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at com.hionshop.hionevent.CameraActivity.rotate(CameraActivity.java:168)
at com.hionshop.hionevent.CameraActivity.onActivityResult(CameraActivity.java:195)
at android.app.Activity.dispatchActivityResult(Activity.java:7539)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4485)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4532)
at android.app.ActivityThread.-wrap20(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
at android.os.Handler.dispatchMessage(Handler.java:105)
CameraActivity.java:168
}
private Bitmap rotate(Bitmap bitmap, float degree) {
Matrix matrix = new Matrix();
matrix.postRotate(degree);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}//밑줄부분이 168
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath);
ExifInterface exif = null;
try {
exif = new ExifInterface(mCurrentPhotoPath);
} catch (IOException e) {
e.printStackTrace();
}
int exifOrientation;
int exifDegree;
if (exif != null) {
exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
exifDegree = exifOrientationToDegrees(exifOrientation);
} else {
exifDegree = 0;
}
((ImageView)findViewById(R.id.cameraImageview)).setImageBitmap(rotate(bitmap, exifDegree));
}밑줄 부분이 195