4.0.0-beta1
Pre-releaseBreaking 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
:
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android: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/file Uri uri = intent.getData(); // A new utility method is provided to transform the URI to a File object File file = com.nononsenseapps.filepicker.Utils.getFileForUri(uri); // If you want a URI which matches the old return value, you can do Uri 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.
- You need to add the following to your app's
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.