How can I get the selected text from the web view in honeycomb

289 views
Skip to first unread message

Manoj chauhan

unread,
Nov 1, 2011, 2:05:34 AM11/1/11
to android-platform
I have tried it with clipboard manager but coudn't be able to get the
text selected in web view. Please tell me how can I get the selected
text from the web view in honeycomb.

Belvedere Computer Services

unread,
Nov 1, 2011, 2:39:41 AM11/1/11
to android-platform
WebView is a simple display

http://developer.android.com/guide/topics/ui/dialogs.html

is likely what you need

Manoj chauhan

unread,
Nov 1, 2011, 4:26:05 AM11/1/11
to android-platform
Actually I want select any text in webview and want to save the
selected text in database. How would it be done.

On Nov 1, 11:39 am, Belvedere Computer Services <fa829...@gmail.com>
wrote:

Belvedere Computer Services

unread,
Nov 1, 2011, 4:31:43 AM11/1/11
to android-platform
what they are using is widgets ~ you put one up - get the text = they
use something called sql + just put that in a search box on the
developer docs and follow it down

Manoj chauhan

unread,
Nov 1, 2011, 6:55:03 AM11/1/11
to android-platform
I didn't get you. Can you please elaborate.

On Nov 1, 1:31 pm, Belvedere Computer Services <fa829...@gmail.com>

Manoj chauhan

unread,
Nov 1, 2011, 10:28:30 AM11/1/11
to android-platform
Please tell the solution of this problem. I am grappling with this
form the whole day.

maren gaaya

unread,
Nov 1, 2011, 12:41:15 PM11/1/11
to android-...@googlegroups.com
to select text in webview you must add :
  • in oncreate method: webviewKey.addJavascriptInterface(new IJavascriptHandler(), "cpjs"); //where webviewKey is your webView
  •  final class IJavascriptHandler {
    IJavascriptHandler() {
    }

    public void getMyText(String myText) {
       // this is called from JS
    System.out.println(myText);
    }
 
  }

  • private class myWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
  public void onPageFinished(WebView view, String url) {
     view.loadUrl("javascript:window.cpjs.getMyText(document.getElementById('myText').innerHTML);void(0);");
    
  }
}

I hope this helpuful

Dinesh Subramanian

unread,
Apr 20, 2012, 2:46:48 AM4/20/12
to android-...@googlegroups.com
Hi,
     this code is not working for me. Can u give me the full sample source code.

Dina

unread,
Apr 20, 2012, 2:53:51 AM4/20/12
to android-...@googlegroups.com
Hi,
this code is not working for me. Can you please send full sample source code.


On Tuesday, 1 November 2011 22:11:15 UTC+5:30, gaayam...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages