I think the only way to do this without an Activity
is by using an AccessibilityService
that has the permissions to get the list of windows currently displayed and check if there's a window whose type is AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER
.
For example, you could have the following method to do so:
private boolean inSplitScreenMode(List<AccessibilityWindowInfo> windows) {
for (AccessibilityWindowInfo window : windows) {
if (window.getType() == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER) {
return true;
}
}
return false;
}
check this method when receiving window state changed accessibility events
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if ((event.getEventType() & AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) != 0) {
if (inSplitScreenMode(getWindows()) {
Log.d(TAG, "Split screen mode detected");
} else {
Log.d(TAG, "No split screen");
}
}
}