Closed pratyush019 closed 3 years ago
I'm using this code to compress image, works fine till android 9 but on android 10 file size is of 0 bytes
try { new Compressor(this) //.setMaxWidth(640) // .setMaxHeight(480) // .setQuality(75) .setCompressFormat(Bitmap.CompressFormat.JPEG) .setDestinationDirectoryPath(new File(this.getExternalCacheDir(),"images").getAbsolutePath()) .compressToFile(new File(getPath(uri))); } catch (IOException e) { e.printStackTrace(); }
From android 10 you can't access files directly from apps folder. Implementation was right but i had permission related issue. Problem solved now.
I'm using this code to compress image, works fine till android 9 but on android 10 file size is of 0 bytes
try { new Compressor(this) //.setMaxWidth(640) // .setMaxHeight(480) // .setQuality(75) .setCompressFormat(Bitmap.CompressFormat.JPEG) .setDestinationDirectoryPath(new File(this.getExternalCacheDir(),"images").getAbsolutePath()) .compressToFile(new File(getPath(uri))); } catch (IOException e) { e.printStackTrace(); }