JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

createInputStream fails on some Android version

Open talaviram opened this issue 2 years ago • 1 comments

Thread: https://forum.juce.com/t/weird-createinputstream-behaviour-android/46016/43

Steps to reproduce:

  1. Create an emulator with API25 and API30
  2. From a file chooser (the native one didn't work for me well on API25 for custom extensions / unknown MIME), choose a file.
  3. 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"

talaviram avatar Sep 29 '21 07:09 talaviram

This functionality is now provided through AndroidDocument::fromDocument and AndroidDocument::createInputStream.

Related forum post here

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.

reuk avatar May 23 '22 14:05 reuk