FileChooser doesn't work correctly on Android?

Dear (pro)Jucers,

FileChooser is behaving strangely on Android. When I’m using i.e. *wav as a filter
_fileChooser.reset(new FileChooser("Select file...", File(), "*.wav"));
it works correctly, it blends out all non wav files but when I use i.e. .json as a filter
_fileChooser.reset(new FileChooser("Select file...", File(), "*.json"));
it doesn’t blend out anything and I can choose any file.

On Windows both cases work correctly so can it be that this is some Android related bug or am I doing something wrong?
I’m working on JUCE v.7.0.2.


The native android file chooser only supports filtering files by mime-type and not file extensions. JUCE needs to convert your file extension to a mime-type to be able to work. The conversion table can be found here.

As you see, the json file type is missing. Can you add it manually (i.e. {'json', 'application/json'} and see if this works? If yes, then we will add it to the develop branch.

I’ll also discuss with the team if we may want to extend the FileChooser API to specify mime-types directly. Or maybe add APIs to register additional mime-types to the conversion table at run-time. Regardless, we definitely need to update the documentation of the FileChooser class to reflect how it behaves internally on Android.


Hi @fr810. That did the trick! Thanks :+1:

With commit e30f6e7 the file-extension/mime-type for .json files was now added to JUCE’s internal mime-type table.

Commit 4054e2 also added the ability for you to add your own custom file-extension/mime-type associations at runtime via a newly introduced static FileChooser method: FileChooser::registerCustomMimeTypeForFileExtension.

We also fixed a bug where the native file chooser would sometimes be displayed multiple times in a row even if you only invoked it a single time (commit 9d5b41e).

All these commits can be found on the develop branch.

1 Like

Thanks for the register custom! You will probably want to add FLAC to your internal list though:

{ "flac",      "audio/x-flac" },   
1 Like

To add to that, all of the Xiph formats are missing: MIME Types and File Extensions - XiphWiki