0

I am using Android's WebView as the rendering engine for a browser. I would like to be able to get an image's title. For example, when browsing to https://www.xkcd.com/327/ on a desktop, mousing over the comic displays the following text: "Her daughter is named Help I'm trapped in a driver's license factory." The source code for the comic is as follows:

<img src="//imgs.xkcd.com/comics/exploits_of_a_mom.png" title="Her daughter is named Help I&#39;m trapped in a driver&#39;s license factory." alt="Exploits of a Mom" />

Using WebView.HitTestResult.getExtra() pulls the src. Does anyone know of a way to get the title?

3
  • you might try WebView.evaluateJavascript(), see stackoverflow.com/questions/19788294/…. This might be challenging if you don't control the web content, but it allows you to run your own javascript code against the DOM and return data.
    – CSmith
    Dec 23, 2016 at 14:31
  • WebView.evaluateJavascript() is an interesting idea. As you point out, implementing it is difficult if you don't control the web content. In my case, I am building a browser that needs to be able to pull an image title from any image on any website and display it in a context menu. Dec 23, 2016 at 18:22
  • I added a feature request to the Android project to add this functionality. code.google.com/p/android/issues/detail?id=231063 Dec 27, 2016 at 19:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.