send text containt of the webpage instead of url in android webview app -
i have android webview app , have added share action in it, shares url of current page of webview. want send text content of page instead of url. please me share intent. following code share intent.
case r.id.menu_item_share: { intent shareintent = new intent(intent.action_send); shareintent.settype("text/plain"); shareintent.putextra(intent.extra_text, mywebview.geturl()); startactivity(intent.createchooser(shareintent, "share website!")); shareintent.setpackage("com.whatsapp"); break; //or, return true;
if need content of web page, please try this.
url url = new url("http://www.google.com/"); urlconnection con = url.openconnection(); pattern p = pattern.compile("text/html;\\s+charset=([^\\s]+)\\s*"); matcher m = p.matcher(con.getcontenttype()); string charset = m.matches() ? m.group(1) : "iso-8859-1"; reader r = new inputstreamreader(con.getinputstream(), charset); stringbuilder buf = new stringbuilder(); while (true) { int ch = r.read(); if (ch < 0) break; buf.append((char) ch); } string str = buf.tostring();
Comments
Post a Comment