'How to detect what the content on the display is?

I have an app that rotates other apps. It uses an accessibility service so I have the ability to retrieve screen content.

Say I'm rotating a game called Geometry Dash to the portrait direction. Sometimes it will rotate correctly and look like this:

enter image description here

But other times it incorrectly appears like this:

enter image description here

Is it possible to detect when half the screen is black like in the second pic?

Perhaps using AccessibilityNodeInfo is the key since that class gives information about what's on the screen?



Solution 1:[1]

You could do it easily be loading the content of the screen into a bitmap then you can split the bitmap in two parts.

Check if one of them is only black.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1