私の問題
内部データ ディレクトリのディレクトリに画像を保存するカメラの意図があります。
以下を使用してディレクトリを作成しました。
File mydir3 = new File(this.getApplicationContext().getFilesDir(),File.separator+"MyApplication"+File.separator+CCPhotoManager.DIRECTORY+File.separator+PhotoManager);
mydir3.mkdirs();
次に、以下に示すように、指定された名前でファイルを作成します。
String filePath = this.getApplicationContext().getFilesDir()+File.separator+"MyApplication"+File.separator+PhotoManager+File.separator+PhotoManager().getNewPhotoFileName()+PhotoManager;
File file = new File(filePath);
次に、画像が保存されない理由は、カメラがアプリケーションのデータ ディレクトリにアクセスする権限を持っていないためでありFileOutputStream
、権限を変更するために使用する必要があることをどこかで読みました。ただし、ファイルのパスにパス区切り文字があるため、使用できませんでしopenFileStream(filePath,Context.MODE_WORLD_WRITABLE);
た。
これが私が以下を試した理由です。
try {
FileOutputStream fos = new FileOutputStream(file);
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ただし、以下のコードを使用して作成されたファイルに画像が保存されないため、これは明らかに機能しません。
Uri uriSavedImage=Uri.fromFile(file);
Log.d("PhotoManager", "adding extra to intent: "+uriSavedImage.toString());
Intent launchcameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
launchcameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(launchcameraIntent,CAMERA_PIC_REQUEST);
私の質問
内部データのカスタム ディレクトリに画像を保存するカメラ インテントを取得するにはどうすればよいですか?
前もって感謝します