I am implementing an app using camera to capture photo . But the camera is capturing even if i don't click , and saving it in the Picture Directory . Photos captured without clicking are saved in hte directory with 0 o size . As solution , i wanted check the size of each image using their path to get their size but the problem is when i try to get their size , even photos that have size ( photos ,i've captured by clicking) return 0o as their size but i want to delete them. How can i figure out it ?
public void onCapturePhoto(String fileName){
//Intent to take photos
File storageDirectory = requireActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
try {
Log.d("#picName",fileName);
File imageFile = File.createTempFile(fileName,".jpg",storageDirectory);
currentPhotoPath = imageFile.getAbsolutePath();
Uri imageUri= FileProvider.getUriForFile(requireActivity(),"com.ticanalyse.mheath.bf",imageFile);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
startActivityForResult(intent,1);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK) {
}
}
Ok, I got you. This may helps:-