Take the 2-minute tour ×

I want to add the bookmark function to my app, when I clicked on the webview which display the HTML files (The file's main part is string), I want to capture the first line of the content which display on the screen. Anyone knows the answer?

Thanks very much in advance.


share|improve this question

2 Answers 2

If there is a link into the WebView and you want to do a specific action when the user click on this link you must catch the link click using the following code:

Somewhere in your activity code (commonly in the onCreate method):

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.news_details);
    mWebView.setWebViewClient(new MyWebViewClient());

And the WebViewClient class:

class MyWebViewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (DEBUG) {
            Log.d(TAG, "shouldOverrideUrlLoading url= " + url);
        if ( the url is like you want) {
            // TODO: add the code to do what you need to do with the url
            // the webview should not do anything with this link.
            return true;
        } else {
            // let the webview normally handle the link
            return false;

If what you want to do is get the actual displayed content of the WebView, there is no API to do that.

Have a look on those post:

Is it possible to get the HTML code from WebView

retrieving webview content (android app)

Both redirect on this website:


share|improve this answer

you can identify the some content of the page as It contains img tag or not Use this API of webView click here

 WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
 int i=hr.getType() ;

and use the int values of this class for the content

Hope it help

share|improve this answer

Your Answer


