I have a WebView pointing to an HTML file, which will contain a
clickable div containing some formatted text.  I would like the click
to copy the contents of the div (i.e. innerHTML) back to Java to be
inserted in an email.

Current Java code:

private WebSettings webSettings;
private WebView mWebView;

.........

mWebView = (WebView) findViewById(R.id.webview);
webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(false);
mWebView.addJavascriptInterface(new JavaScriptInterface(), "main");
max_section = 6;
section = 1;
mWebView.loadUrl("file:///android_asset/www/ebook" + section +
".html");

..........

mWebView.addJavascriptInterface(new Object()
                {
                          public void emailClick(Object obj)
                          {
                                // Perform action on click
                                        String email_subject = "title" + " 
(code)";
                                        String email_text = "From the 
ebook:\n\n"
                                                + obj.value;  //<--- this 
should be the formatted text from HTML
div
                                        Intent sendIntent = new 
Intent(Intent.ACTION_SEND);
                                        sendIntent.setType("text/html");
                                        
sendIntent.putExtra(Intent.EXTRA_SUBJECT, email_subject);
                                        sendIntent.putExtra(Intent.EXTRA_TEXT, 
email_text);
                                        startActivity(sendIntent);
                          }
                        }, "eobj");

Current HTML/Javascript code:

..........

<div id="email_11" onclick="eobj.emailClick(self);">
     <p class="ecode">
          DATA new (DROP=_nvar _cvar);
           <br>
           &nbsp;&nbsp;SET old (RENAME=(cvar = _cvar nvar = _nvar));
           <br>
           RUN;
     </p>
</div>

How do I get the formatted div text back to Java?

...........hollandnumerics

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to