问题
I am creating an application in which i need to use AccessibilityService. And there is no problem to get get the window content of other applications. I have detected all available child from the window content and the child are showing in AccessibilityNodeInfo. Now I have a webview in AccessibilityNodeInfo And i need to get the URL of that WebView but there is no way to convert the AccessibilityNodeInfo into the relevant View.
Is there any way to get the webview from AccessibilityNodeInfo ?
回答1:
No, because the WebView
is in another process, not yours.
回答2:
There is not a way to access all of the properties of the WebView, as a WebView. AccessibilityNodeInfo objects are completely separate from the objects that they represent.
However, since you are in control of the application, you could easily provide this information in the content description of one of the elements of your application, which would then easily be accessed by your Accessibility Service. Just be sure not to break the general accessibility of your application, when using this somewhat hackish solution.
Note: I would question the design decisions that lead you to this line of thinking. Perhaps a more general description of what you're trying to do, would allow us (the Stack Overflow community) to suggest a better way of accomplishing similar things.
来源:https://stackoverflow.com/questions/33318083/how-to-get-webview-from-accessibilitynodeinfo