2

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 ?

Manish Agrawal
  • 551
  • 2
  • 6
  • 22
  • You say application and accessibility service. Are you designing the application, or the service? Or both? What you want to do is not possible... the way you state it. However, the intent behind what you are trying to achieve is fairly simple, depending on which side of the equation you are working on. – MobA11y Oct 24 '15 at 23:45
  • @ChrisCM : I am designing both. I need to use accessibility service to fetch the another app's WebView URL. I am able to retrieve the content of the window of another app and It returns the WebView class name in AccessibilityNodeInfo object which is right as Expected and Now i need to fetch the loaded URL of that WebView. Please help if there is a way to get the loaded URL from that AccessibilityNodeInfo Or Is there any way to access all properties of that WebView from AccessibilityNodeInfo. – Manish Agrawal Oct 26 '15 at 08:00
  • 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 WebView, you could easily provide this information in the WebView's content description, which would then easily be accessed by your Accessibility Service. Just be sure not to break the accessibility of the objects within the webview when doing so. – MobA11y Oct 26 '15 at 16:00

2 Answers2

1

No, because the WebView is in another process, not yours.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So, Is there any way to find out the loaded URL inside that webview ?? – Manish Agrawal Oct 24 '15 at 12:26
  • Not that I am aware of. After all, there may not *be* a URL, as you do not need a URL to populate a `WebView`. – CommonsWare Oct 24 '15 at 12:28
  • The WebView must contains a URL and i need to find that URL. I am only able to get the Text and contentDescription of the Node. Is there any way to get access more than this of a AccessibilityNodeInfo ? – Manish Agrawal Oct 24 '15 at 12:37
  • @ManishAgrawal: "The WebView must contains a URL" -- no, it does not. "Is there any way to get access more than this of a AccessibilityNodeInfo ?" -- no. – CommonsWare Oct 24 '15 at 12:40
1

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.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • 1
    Let me explain : suppose i am on the third party app say "Amazon". Now i am able to access all of the window content using accessiblity service and accessibility event type : "typeViewFocused". And I have a condition that if the window content contains class name "android.webkit.WebView" then I have to find the loaded URL for that webview. But couldn't find the URL, I can access all the content inside webview but I dont need the content of WebView i only need that URL which that webview used to load the content. Even i have checked all AccessibilityNodeInfo objects but not able to find URL. – Manish Agrawal Oct 27 '15 at 07:39
  • So, to clarify, you are NOT designing both. You are only in control of the accessibility service. This would be contrary to your other comment... Under this description, there is no reliable way to get this information. – MobA11y Oct 27 '15 at 14:35