In my application, I am showing epub HTML files in webview using EPUBLIB.
My problem is that I want to use bookmark functionality for my epub reader. For that I want to fetch text from webview which is showing page from my epub’s HTML file and then use that text in my bookmark activity to show the user what they have bookmarked.
How can I achieve this?
In my application, I am showing epub HTML files in webview using EPUBLIB .
Share
Getting the plain text content from a webview is rather hard. Basically, the android classes don’t offer it, but javascript does, and Android offers a way for javascript to pass the information back to your code.
Before I go into the details, do note that if your html structure is simple, you might be better off just parsing the data manually.
That said, here is what you do:
To clarify, I’ll post a working (but very rough) code example below. It displays a webview on the top, and a textview with the text-based contents on the bottom.
Using the following main.xml: