NoNonsense-FilePicker v4.0.0-beta1 Release Notes
Release Date: 2016-10-22 // over 7 years ago-
💥 Breaking changes
You are now required to define a
FileProvider
in your manifest for the SD-card picker 101aa70Due to recent changes in Android 7.0 Nougat, bare File URIs can no longer be returned in a safe way. This change requires you to add an entry to your manifest to use the included
FilePickerFragment
and change how you handle the results.You need to add the following to your app's
AndroidManifest.xml
:<providerandroid:name="android.support.v4.content.FileProvider"android:authorities="${applicationId}.provider"android:exported="false"android:grantUriPermissions="true"> <meta-dataandroid:name="android.support.FILE_PROVIDER_PATHS"android:resource="@xml/nnf_provider_paths" /> </provider>
Then you must change your result handling. Here is a code snippet illustrating the change for a single result (the same applies to multiple results):
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { // The URI will now be something like content://PACKAGE-NAME/root/path/to/fileUri uri = intent.getData(); // A new utility method is provided to transform the URI to a File objectFile file = com.nononsenseapps.filepicker.Utils.getFileForUri(uri); // If you want a URI which matches the old return value, you can doUri fileUri = Uri.fromFile(file); // Do something with the result...}
This change was required in order to fix
FileUriExposedException
being thrown on Android 7.0 Nougat, as reported in #115 and #107.⚡️ Please see the updated activity in the sample app for more examples.
🔄 Changed
Reading multiple selections via
intent.getStringArrayListExtra(AbstractFilePickerActivity.EXTRA_PATHS)
is now available for all Android versions 4fef8f8This field was previously only populated on versions below Android 4.3. If you target Android versions before 4.3, you can now use a single method of getting the results instead of switching based on version number.