0

i want to add share action in my WebView which can share Text content (body of the article) via share action. Note:- I don't want to share URL of the page but the actual text content of the webpage. Following is my codes. MainActivity.java (WebView)

 myWebView.getSettings().setJavaScriptEnabled(true);
            myWebView.loadUrl("https://google.com/");
            WebSettings webSettings = myWebView.getSettings();
            webSettings.setJavaScriptEnabled(true);
            //improve webView performance
            myWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
            myWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            myWebView.getSettings().setAppCacheEnabled(true);
            myWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
            webSettings.setDomStorageEnabled(true);
            webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
            webSettings.setUseWideViewPort(true);
            webSettings.setSavePassword(true);
            webSettings.setSaveFormData(true);
            webSettings.setEnableSmoothTransition(true);
            myWebView.setWebViewClient(new WebViewClient());

case R.id.menu_item_share: {
                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
                startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.menu_item_share)));
                break;
sagar chaudhary
  • 33
  • 1
  • 12
  • this [link](http://stackoverflow.com/questions/8200945/how-to-get-html-content-from-a-webview?answertab=votes#tab-top) might be helpful. – rajesh Aug 01 '16 at 11:07
  • @rajesh i have tried this links,but i don't know how to set share intent after that. – sagar chaudhary Aug 01 '16 at 11:23

0 Answers0