JUCE
JUCE copied to clipboard
createInputStream fails on some Android version
Thread: https://forum.juce.com/t/weird-createinputstream-behaviour-android/46016/43
Steps to reproduce:
- Create an emulator with API25 and API30
- From a file chooser (the native one didn't work for me well on API25 for custom extensions / unknown MIME), choose a file.
- Parse the URL into an InputStream as within the above thread.
Expected: (API25)
- Should get proper stream.
Actual: (API30)
- we get nullptr.
Resolution:
It seems that unless using newer API it's required to add the following to the manifest.
android:requestLegacyExternalStorage="true"
This functionality is now provided through AndroidDocument::fromDocument and AndroidDocument::createInputStream.
Note that, when targeting Android 30, access to arbitrary shared locations must be granted via the Storage Access Framework (that is, the native file chooser).
The requestLegacyExternalStorage workaround only works when targeting Android 29, but apps distributed via Google Play must now target Android 30.