如何从 AccessibilityNodeInfo 获取 webview [英] how to get webview from AccessibilityNodeInfo

查看:60
本文介绍了如何从 AccessibilityNodeInfo 获取 webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,我需要在其中使用 AccessibilityService.并且获取其他应用的窗口内容也没有问题.我已从窗口内容中检测到所有可用的子项,并且该子项显示在 AccessibilityNodeInfo 中.现在我在 AccessibilityNodeInfo 中有一个 webview,我需要获取该 WebView 的 URL,但无法将 AccessibilityNodeInfo 转换为相关视图.

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.

有什么办法可以从 AccessibilityNodeInfo 获取 webview 吗?

Is there any way to get the webview from AccessibilityNodeInfo ?

推荐答案

没有一种方法可以访问作为 WebView 的 WebView 的所有属性.AccessibilityNodeInfo 对象与它们所代表的对象完全分开.

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.

这篇关于如何从 AccessibilityNodeInfo 获取 webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆