내가 찾은
최선의 해결책은 다음과 같습니다 FileProvider 그것은 내부 저장소를 사용 (지원 라이브러리-V4 필요)! https://developer.android.com/reference/android/support/v4/content/FileProvider.html
이 응용 프로그램 요소에 매니페스트에 FileProvider을 정의
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="your.package.name.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/image_path" />
</provider>
추가 권한을 매니페스트 루트 요소 :
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
예를 입술에 대한 귀하의 이미지 경로를 정의/xml/image_path.xml :
(210) <paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="captured_image" path="your/path/"/>
</paths>
자바 :
private static final int IMAGE_REQUEST_CODE = 1;
// your authority, must be the same as in your manifest file
private static final String CAPTURE_IMAGE_FILE_PROVIDER = "your.package.name.fileprovider";
4.1 캡처 의도 :
File path = new File(activity.getFilesDir(), "your/path");
if (!path.exists()) path.mkdirs();
File image = new File(path, "image.jpg");
Uri imageUri = FileProvider.getUriForFile(activity, CAPTURE_IMAGE_FILE_PROVIDER, image);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, IMAGE_REQUEST_CODE);
4.2 onActivityResult를() :
이
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == IMAGE_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
File path = new File(getFilesDir(), "your/path");
if (!path.exists()) path.mkdirs();
File imageFile = new File(path, "image.jpg");
// use imageFile to open your image
}
}
super.onActivityResult(requestCode, resultCode, intent);
}
좋아, 내가 문제였다 직감했다 . SD 카드에 일시적으로 사진을 저장하는 방법을 다시 옮겨야 겠지만, 내 툴킷에 이것을 추가 할 것입니다 :) – sgarman
Context.MODE_WORLD_WRITEABLE을 해결하는 방법에 대한 아이디어가 있으십니까? – superbre
[here] (http://developer.android.com/reference/android/content/Context.html) : ** MODE_WORLD_WRITEABLE이 상수는 API 레벨 17에서 사용되지 않습니다. 세계에서 쓰기가 가능한 파일을 만드는 것은 매우 위험하며 응용 프로그램에 보안 허점이 생길 수 있습니다.강력히 낙담하게됩니다 ** – Atul