-
-
Save PGMacDesign/92cb449b8b4a6ac10a7661f9ff26d9bd to your computer and use it in GitHub Desktop.
For fixing the permissions bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get the photo Uri (Java Uri). Make your adjustments to get the actual path (not shown here) | |
Uri uri = data.getData(); | |
try { | |
//Make a File | |
File fromFile = new File(uri.toString()); | |
//Make a Temp File | |
File tempFile = File.createTempFile("temp_photo", ".jpg", context.getCacheDir()); | |
//One of my Utilities (inspired by Yalantis no less!) Here if you need it: | |
//https://github.com/PGMacDesign/PGMacUtilities/blob/master/app/src/main/java/com/pgmacdesign/pgmacutilities/utilities/FileUtilities.java | |
FileUtilities.copyFile(fromFile, tempFile); | |
//One of my Conversion Utilities. Here if you need it: | |
//https://github.com/PGMacDesign/PGMacUtilities/blob/master/app/src/main/java/com/pgmacdesign/pgmacutilities/utilities/StringUtilities.java | |
uri = StringUtilities.convertJavaURIToAndroidUri(tempFile.toURI()); | |
//Call this so that it will delete when the section / app exists | |
tempFile.deleteOnExit(); | |
} catch (NullPointerException e1){ | |
//Original Uri was null | |
} catch (IOException e){ | |
//File Creation issue | |
} | |
//Then run your cropping on the New Uri here | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment