Ok, so I think I have a handle on this and why my stuff is not working and the demo does.
When building a standalone, this code gets executed at startup for OSX and Android:
#if JUCE_IOS || JUCE_ANDROID
void timerCallback() override
auto newMidiDevices = MidiInput::getDevices();
for (auto& newDevice : newMidiDevices)
if (! lastMidiDevices.contains (newDevice))
deviceManager.setMidiInputEnabled (newDevice, true);
It opens all the MIDI devices it can find. Any calls to MidiInput::OpenDevice() on Android will then fail - seems to be ok on iOS - maybe this is because iOS MIDI is mulit-ported like OSX and Android isn’t like Windows? Anyway, I commented out this code and my code now works as expected. So it seems on Android that we have to go through the DeviceManager created at startup. As the JuceDemo is not running the standalone code, it does not see this issue.
I’m not sure how to get hold of the DeviceManager class that lives inside the standalone filter window from my plugin inside my code to use it - can you tell me how?
I guess ideally, if we want to manage MIDI devices ourselves, without using the DeviceManager class, it would be nice to be able to tell the Android build not to go and open all the MIDI input devices at startup so that the rest the same behaviour is seen across all platforms. Or maybe there’s a call on DeviceManager to tell it to close everything - haven’t checked yet