I’m trying to save my app state in Android and i’m doing it by using the AndroidDocument class and its derivatives. Everything works, so i can reach the directory and i can get the file URL. The problem is, when i call showAudioResource() with that URL, which is the function inside the AudioPlaybackDemo,
the app crashes and the log says :
2024-05-17 18:29:09.317 5720-5720 JUCE com.yourcompany.audioguibasicapp I SAVE LOG : Text in file savedState is content://com.android.externalstorage.documents/document/primary%3ADocuments%2FTH%20-%203SIS%2Fifyoustillwerehere.wav
2024-05-17 18:29:09.325 6872-25174 DatabaseUtils com.android.externalstorage E Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary%3ADocuments%2FTH%20-%203SIS%2Fifyoustillwerehere.wav from pid=5720, uid=10226 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:1012)
at com.android.externalstorage.ExternalStorageProvider.enforceReadPermissionInner(ExternalStorageProvider.java:167)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:814)
at android.content.ContentProvider$Transport.query(ContentProvider.java:254)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:107)
at android.os.Binder.execTransactInternal(Binder.java:1525)
at android.os.Binder.execTransact(Binder.java:1464)
In particular i see that line here :
java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary%3ADocuments%2FTH%20-%203SIS%2Fifyoustillwerehere.wav from pid=5720, uid=10226 requires that you obtain access using ACTION_OPEN_DOCUMENT or related
Obviously, if i call it with the URL gained from a FileChooser, the wav file gets loaded correctly.
Looking at Android Developers site, i see at this page that it’s an Intent i should be requesting.
Is there a way, while staying in JUCE and in C++, to do that?