Skip to content

Commit

Permalink
possible fix for android 11 external storage issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTomAlx committed Feb 11, 2021
1 parent 26b548e commit dd57d9f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/src/main/java/com/scanlibrary/PickImageFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*/
public class PickImageFragment extends Fragment {
int camorgal = 0;
private String imagePath = "";
private View view;
private ImageButton cameraButton;
private ImageButton galleryButton;
Expand Down Expand Up @@ -62,6 +63,7 @@ private void init() {
cameraButton.setOnClickListener(new CameraButtonClickListener());
galleryButton = (ImageButton) view.findViewById(R.id.selectButton);
galleryButton.setOnClickListener(new GalleryClickListener());
imagePath = getActivity().getApplicationContext().getExternalCacheDir().getPath() + "/scanSample";
if (isIntentPreferenceSet()) {
handleIntentPreference();
} else {
Expand All @@ -71,7 +73,7 @@ private void init() {

private void clearTempImages() {
try {
File tempFolder = new File(ScanConstants.IMAGE_PATH);
File tempFolder = new File(imagePath);
for (File f : tempFolder.listFiles())
f.delete();
} catch (Exception e) {
Expand Down Expand Up @@ -148,7 +150,7 @@ private File createImageFile() {
clearTempImages();
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new
Date());
File file = new File(ScanConstants.IMAGE_PATH, "IMG_" + timeStamp +
File file = new File(imagePath, "IMG_" + timeStamp +
".jpg");
fileUri = Uri.fromFile(file);
return file;
Expand Down

0 comments on commit dd57d9f

Please sign in to comment.