Handling multi-window in Android 7.0+

(also cross posted in Stack Overflow today)

Hi, how are folks handling android’s multi-window support in cordova or using browser events? Specifically, I am trapping the pause event in my app and doing cleanup because when the app is not running in multi-window mode, it actually means the app is going to the background. I use this callback to clear up some expensive memory resources (which includes live video feeds being displayed).

However, in multi-window mode, when you lay two apps next to each other and perform any activity on the other app, cordova generates the pause event. Obviously, in this case, I don’t want to do the cleanup because the UI is still visible.

So the question is, does cordova offer a way to:
a) Either detect if the app is running in multi-window mode
b) Or, differentiate between a pause event and a stop event (as described in this SO thread)

I noticed this note in cordova-discuss but the author doesn’t mention which one line change. I only found a change related to androidresizable being set to true but that is not my problem. The app does take its window in multi-window and doesn’t go full screen. Its the events that are causing issues.

I cobbled together a cordova plugin that returns true if the app is in multi-window and false if not. So far I’ve tested only on an Android 8 emulator (returns true or false) and an Android 6 emulator (always false).

This is my first plugin and if its bad, feel free to PR and improve.

Link: https://github.com/pliablepixels/isMultiWindow