2011-08-14 5 views
5

카메라를 사용할 수있는 방법이 있지만 이미지를 임시로 저장합니까? 그때 내가 촬영 한 이미지를 얻기 위해() onActivityResult를 사용하고, 카메라를로드하려면 다음 코드를 사용하고 (있는 경우 ...)카메라를 시작하지만 이미지를 저장하지 마십시오

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 

문제가 촬영이됩니다 것을, 그것은 SD 카드에 저장됩니다.

편집 이미지를 얻을 수 없다 Howver 내가

File imageFile = new File(imagePath); 
imageFile.delete(); 

을 활동 데이터를 반환 (onActivityResult) 사용하고 있습니다 때 의도는 다음 코드

String imagePath; 

imagePath = Environment.getExternalStorageState() + "/images/myimage.jpg"; 
File file = new File(imagePath); 
Uri outputFileUri = Uri.fromFile(file); 

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); 
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); 

에 의해 불려

삭제됨 또한, 내 갤러리 응용 프로그램으로 향하면 이미지에 기본 이름 (예 : image57465.jpg)이 있는데, 나는 실제로 작동하지 않고 cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);을 asuming하고 있습니다.

EDIT 2

사실, 파일은 SDCARD에 저장되고, 올바르게 삭제. 그러나 미리보기 이미지가 저장되는 것 같습니다. 내가 그것을 사용한 후에 그것을 삭제할 수 있도록 미리보기 경로를 어떻게 얻는 지 아이디어가 있습니까? 캡처 & 절약, 변수 및 활동이 저장

File mFile=new File(variable); 
mfile.delete(); 

답변

5

음에서 파일 (변수)를 제거 후 완료되면 매장의 ImagePath의시

+0

'경로'는 어디에서 왔습니까? – dotty

+0

위 코드를 업데이트했습니다. – dotty

1

, 당신은 단지 이미지를 삭제할 수 없습니다 당신이 그것을 사용한 후에? 카메라 API 사양을 신속하게 확인한 결과 이미지를 임시로 플래그를 지정할 수 있음을 나타내는 항목을 찾을 수 없었습니다.

는 다음과 같은 시도 :

public onActivityResult(int request, int result, Intent data) { 

    if(request == CAPTURE_IMAGE) { 

     if(result == RESULT_OK) { 

      /*Use the image in the way you want to here and save the path */ 

      //Delete the image 
      File image = new File(path); 
      image.delete(); 

     } 

    } 

} 

이 당신을 위해 밖으로 작동하는지 알려주세요.

+0

코드를 업데이트했습니다. 제발 좀 봐주세요. – dotty

+0

이것을 다음으로 대체하십시오. imagePath = Environment.getExternalStorageState() + "/images/myimage.jpg"; with imagePath = getExternalStorageDirectory() + "/images/myimage.jpg"; 다시 시도하십시오 –

관련 문제