0

내 응용 프로그램에서 이미지를 캡처하지만 캡처 된 이미지 URI가 표시되지 않도록 기본 카메라 앱을 엽니 다. 개방 카메라Android 기본 카메라 캡처 이미지 반환 이미지 URI null

코드 - -

private void initTmpUris() { 
    File proejctDirectory = new File(CameraUtil.FOLDER_PATH + File.separator + CameraUtil.FOLDER_NAME); 
    if (!proejctDirectory.exists()) { 
     proejctDirectory.mkdir(); 
    } 
    File tempDirectory = new File(proejctDirectory, "temp"); 
    if (!tempDirectory.exists()) { 
     tempDirectory.mkdir(); 
    } else { 
     // delete all old files 
     for (File file : tempDirectory.listFiles()) { 
      if (file.getName().startsWith("tmp_") 
        || file.getName().startsWith("croped_")) { 
      } 
     } 

    } 
    capturedImageUri = Uri.fromFile(new File(tempDirectory, "tmp_" 
      + String.valueOf(System.currentTimeMillis()) + ".jpg")); 

    File extraOutputFile = new File(tempDirectory, "croped_" 
      + String.valueOf(System.currentTimeMillis()) + ".jpg"); 

    extraOutputFile.setWritable(true); 
    cropImageUri = Uri.fromFile(extraOutputFile); 
} 

코드를하여 onActivityResult에서 - - 내가

case REQ_CODE_PICK_FROM_CAMERA_WITHOUT_CROP: { 

      if (resultCode == RESULT_OK) { 
       if(null!=capturedImageUri) { 
        String imagePath = capturedImageUri.getPath(); 
        File file = new File(imagePath); 
        onSingleImageSelected(reqCodeStarter, file, imagePath, 
          get_Picture_bitmap(file)); 
       } 


      } else { 
       onMediaPickCanceled(reqCodeStarter, 
         REQ_CODE_PICK_FROM_CAMERA_WITHOUT_CROP); 
      } 

     } 
     break; 

initTmpUris(); 
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    intent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri); 
    intent.putExtra("return-data", true); 

코드 저장하는 이미지 경로를 생성하기위한 다음은 내 코드입니다 captivationImageUri는 삼성 s7 장치에서, 다른 장치에서는 캡쳐 된 이미지의 반환 URL입니다.

+1

os use가 Marshmallow 인 경우 런타임 권한이 있는지 확인하십시오. – siddhesh

답변

2

Manifest 파일의 activity 태그에이 코드를 추가하십시오.

android:configChanges="orientation|keyboardHidden|screenSize" 

현재 활동을 파괴하고 다시 만들지 않아 결과를 얻을 수 없습니다.

+1

감사합니다. – Ravi

관련 문제