diff --git a/examples/GUI/ImagesDemo.h b/examples/GUI/ImagesDemo.h index 226a3e94c24e..18a850234703 100644 --- a/examples/GUI/ImagesDemo.h +++ b/examples/GUI/ImagesDemo.h @@ -56,9 +56,6 @@ class ImagesDemo final : public Component, ImagesDemo() { setOpaque (true); - imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true); - directoryThread.startThread (Thread::Priority::background); - fileTree.setTitle ("Files"); fileTree.addListener (this); fileTree.setColour (TreeView::backgroundColourId, Colours::grey); @@ -81,6 +78,20 @@ class ImagesDemo final : public Component, -0.7); // and its preferred size is 70% of the total available space setSize (500, 500); + + RuntimePermissions::request (RuntimePermissions::readMediaImages, + [this] (bool granted) + { + if (! granted) + { + AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, + "Permissions warning", + "External storage access permission not granted, some files" + " may be inaccessible."); + } + imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true); + directoryThread.startThread (Thread::Priority::background); + }); } ~ImagesDemo() override diff --git a/modules/juce_core/native/juce_Files_android.cpp b/modules/juce_core/native/juce_Files_android.cpp index b91e05339c1c..4f80de5e4896 100644 --- a/modules/juce_core/native/juce_Files_android.cpp +++ b/modules/juce_core/native/juce_Files_android.cpp @@ -297,7 +297,7 @@ struct AndroidContentUriResolver if (jniCheckHasExceptionOccurredAndClear()) { - // An exception has occurred, have you acquired RuntimePermission::readExternalStorage permission? + // An exception has occurred, have you acquired RuntimePermissions::readExternalStorage permission? jassertfalse; return {}; }