안녕하세요
기본 카메라 기능을 공부하고 있습니다.
Developers와 다른 예제들을 찾아서 공부했을 때는
Android/data/패키지명/files/Pictures
위 폴더에만 저장이 되고 공용폴더에는 저장이 안되더라구요...
(제가 딱 구현하고 싶은 저장 방법이 B612라는 카메라 어플입니다.
B612 찍으면 갤러리에 B612 폴더가 생기면서 저장이 되고
전체 사진으로 보기에도 나오는..)
혹시, 아시는 방법이 있을까요?
겸손히 간절하게 부탁드립니다....
하단에 제 코드들 첨부드립니다
먼저 file_paths.xml
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="my_images"
path="Android/data/com.example.atthatcustomerwithcal/files/Pictures"/>
</paths>
Manifest
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="패키지명.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
createFile();
//사진 촬영 후 썸네일만 띄어줌. 이미지를 파일로 저장
private File createImageFile() throws IOException{
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName,
".jpg",
storageDir
);
mCurrentPhotoPath = image.getAbsolutePath();
Log.d("123", mCurrentPhotoPath+"");
return image;
}
dispatch 인텐트 메서드
//카메라 인텐트를 실행하는 부분
private void dispatchTakePictureIntent(){
Intent takePictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
if(takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try { photoFile = createImageFile();}
catch (IOException ex){}
if(photoFile != null){
Uri photoUri = FileProvider.getUriForFile(this,"com.example.atthatcustomerwithcal.fileprovider",photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}