0

我正在构建一个 android 应用程序,我想在其中读取从其他应用程序触发的 WindowManager(System Alert) Alert Text。

假设有一些应用程序,如真正的来电者,并且在每次通话结束后,该应用程序在 android 的 WindowManager(系统警报)中显示该特定电话号码的一些信息,我想读取与显示在中的该电话号码相关的所有这些信息WindowManger(系统警报)使用我的应用程序。

有什么方法可以读取或获取其他应用程序触发的 WindowManger(System Alert) 警报对话框的子视图。

4

2 回答 2

0

一种方法是编写无障碍服务(https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html)并挂钩一些无障碍事件。也许是 TYPE_WINDOW_STATE_CHANGED?

于 2017-05-17T08:13:10.160 回答
0

您可以尝试AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS在无障碍服务中设置并监听诸如

    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();
    }
于 2017-05-17T13:25:19.103 回答