Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:31:38+00:00 2026-05-30T22:31:38+00:00

In my application, I am showing epub HTML files in webview using EPUBLIB .

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:31:39+00:00Added an answer on May 30, 2026 at 10:31 pm

    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:

    1. Enable javascript
    2. Add your own javascript interface class, to allow the javascript to communicate with your Android code
    3. Register your own webviewClient, overriding the onPageFinished to insert a bit of javascript
    4. In the javascript, acquire the element.innerText of the tag, and pass it to your javascript interface.

    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.

    package test.android.webview;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.TextView;
    
    public class WebviewTest2Activity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            WebView webView = (WebView) findViewById(R.id.webView);
            TextView contentView = (TextView) findViewById(R.id.contentView);
    
            /* An instance of this class will be registered as a JavaScript interface */ 
            class MyJavaScriptInterface 
            { 
                private TextView contentView;
    
                public MyJavaScriptInterface(TextView aContentView)
                {
                    contentView = aContentView;
                }
    
                @SuppressWarnings("unused") 
    
                public void processContent(String aContent) 
                { 
                    final String content = aContent;
                    contentView.post(new Runnable() 
                    {    
                        public void run() 
                        {          
                            contentView.setText(content);        
                        }     
                    });
                } 
            } 
    
            webView.getSettings().setJavaScriptEnabled(true); 
            webView.addJavascriptInterface(new MyJavaScriptInterface(contentView), "INTERFACE"); 
            webView.setWebViewClient(new WebViewClient() { 
                @Override 
                public void onPageFinished(WebView view, String url) 
                { 
                    view.loadUrl("javascript:window.INTERFACE.processContent(document.getElementsByTagName('body')[0].innerText);"); 
                } 
            }); 
    
            webView.loadUrl("http://shinyhammer.blogspot.com");
        }
    }
    

    Using the following main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.5" />
    
        <TextView
            android:id="@+id/contentView"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.5" />
    
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that showing maps using OSMDroid. I want to get
I'm using http://code.google.com/p/flex-iframe/ for showing html in an flex application. To set this up
hi i am using a mapview in my application.it showing correctly but the problem
I have an application showing standard html pages. I use UIWebView for html. When
Currently I am facing the problem that my application is showing long GC times
I have devoleped an application and the problem with that application is that Its
in my application bus error is showing and application crash ..i want to know
I'm writing a Silverlight application that is showing a pie chart of completed items
Using AppleScript you can create a script that runs another application, and then save
I have a flex application showing a chart. I want to give user the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.