[REQUEST] Support multiple windows on Android


Android has Multi-Window support since API 24. Currently SDL requires API >= 26, so all Android versions supported by SDL have this feature.

Android’s Multi-Window support is not limited to displaying multiple apps on one screen, you can also launch multiple activities of the same app (for example, Chrome can do that):
Launch New Activities in Multi-Window Mode - from developer.android.com

Also Android devices can support “freeform windows”, i.e. basically a desktop-like experience.

Currently the code in SDL_androidwindow.c won’t allow opening more than one window:

SDL_SetError(“Android only supports one window”);

I think multiple windows should be supported on Android. Are there any technical challenges that currently prevent this?


1 Like

My understanding is that it only requires API >= 16 to run. See ‘Requirements’ here.

Thank you for the correction.
So that means this feature will also require a check if Multi-Window is supported (API Level < 24) and a fallback to the current behavior if it isn’t.


Currently SDL can run in multi-window, you can resize the window, share the screen with another app, get/lose focus, etc. Indeed it doesn’t allow to create more than one window.

Once, I tried to patch SDL to create several pseudo windows by simply creating several surfaceView, so that windows were in fact “layers”, z-ordered. This worked, but this wasn’t representative of SDL functionnalities.

It should be possible to create several genuine windows with several activities.
Currently SDLActivity creates surfaceview, and when all is ready, starts the C main.
With several windows, it’s going to be a little bit messier, with some re-factoring needed.
A compromise for simplication could be to have a master window (the root activity), and several other.

That would be great, especially knowing that genuine windows can take advantage of Android’s features designed for windows, such as system-wide drag&drop (which is another feature in scope of SDL and worth considering).

What would happen if the user closed the master window in that case?

What parts of SDL do you think would be involved in such refactoring? Is it a lot of work?