Read other application WindowManager(System Alert) Alert in android?

342 Views Asked by At

I am building an android application where I want to read WindowManager(System Alert) Alert Text that is trigger from some other application.

Suppose there is some application like true caller and after the end of each call this application display some information of that particular phone number in WindowManager(System Alert) of android and I want to read all this information related to that phone number which is displayed in WindowManger(System Alert) using my application.

Is there any way to read or to get view child of WindowManger(System Alert) Alert dialog trigger by other application.

2

There are 2 best solutions below

1
On

Think one way would be to write an accessibility service (https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html) and hook to some accessibility events. Maybe TYPE_WINDOW_STATE_CHANGED?

0
On

You can try setting AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS in the accessibility service and listen for events like

    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: {
                AccessibilityNodeInfo nodes = getRootInActiveWindow();
                String nodeText = nodes.getText();
                String nodeContentText nodes.getContentDescription();

                // Also you could cycle through the children repeating the same
                // As an example only taking the first child, you could 
                // loop through or use recursion

                AccessibilityNodeInfo firstNode = nodes.getChild(0)
                String nodeTextFirstChild = firstNode.getText();
                String nodeContentTextFirstChild = firstNode.getContentDescription();
    }