2013-03-28 3 views
2

카메라로 사진을 찍고 싶습니다. 나는이 방법을 수행하고 그것은 작동 :이 작업이 성공하면카메라로 사진 찍기 자르기

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); 
startActivityForResult(intent, CAMERA_REQUEST); 

, 나는 사용자가 즉시 이미지를보고자를 수에 수 있어야합니다. 이 같은 그렇게 할 수

:

 Intent cropIntent = new Intent("com.android.camera.action.CROP"); 
     cropIntent.setDataAndType(Uri.fromFile(new File(file.toString())), "image/*"); 
     cropIntent.putExtra("crop", "true"); 
     cropIntent.putExtra("aspectX", 1); 
     cropIntent.putExtra("aspectY", 1); 
     cropIntent.putExtra("outputX", 256); 
     cropIntent.putExtra("outputY", 256); 
     cropIntent.putExtra("return-data", true); 
     startActivityForResult(cropIntent, CAMERA_REQUEST); 

어떻게 다른 후 하나를 일 때문에 나는이 두 가지 작업을 병합합니까? 나는 startActivityForResult 두 개가 있어야합니까? 병합해야합니까? 아니면 크로 핑 ginfo가 정상 안에 있어야합니까?

getActivity(); 
    if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) { 


        // Cropping code here? another intent? 

     iPP.setImageBitmap(BitmapFactory.decodeFile(file.toString())); 
     imagePath = file.toString(); 
     scaleImage(); 
     new UploadImage().execute(); 
    } 

답변

1

CAMERA_CROP라는 새 상수를 만듭니다.

사진 촬영 후 활동을 시작하면 CAMERA_CROP 요청 코드를 보냅니다.

if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) { 
    ... 
    startActivityForResult(cropIntent, CAMERA_CROP); 
} 

자르기 활동에서 돌아 오면 요청 코드를 처리하십시오.

if (requestCode == CAMERA_CROP && resultCode == Activity.RESULT_OK) { 
... 
} 
+0

내 후속 문제를 파악했습니다. 감사합니다. 올바른 것으로 표시되었습니다. – KickingLettuce