title: How do I send webview content body via email?
body: <p>Currently in my app, I am using a webview for my html content to be displayed(which is coming via assets folder as expected,just to clarify). However, I have integrated send via email functionality and I see the subject body and title as null instead of content in focus in the selected email of choice. (say I pick gmail when I select my send via email option. I see the content body as null instead of the content in the webview).Any one has done this or has an idea, how to go about the same?
  Here's my code:
  My EmailUtils class:</p>
  
  <pre><code>public class EmailUtils {
      public static String FEEDBACK_EMAIL = "Android.Feedback@mycompany.com";
  
      public static void shareNewsViaEmail(final Fragment fragment, final String emailSubject, final String emailBody){
          shareNewsViaEmailEx(fragment.getActivity(), emailSubject, emailBody);
      }
  
      public static void shareNewsViaEmailEx(final Context context, final String emailSubject, final String emailBody){
          final Intent emailIntent = new Intent(Intent.ACTION_SEND);
          emailIntent.setType("text/html");
          final String subjectAppendText = " " + context.getResources().getString(R.string.email_subject_append);
          emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject + subjectAppendText);
          emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
          context.startActivity(Intent.createChooser(emailIntent, "Send Email"));
      }
  
  }
  </code></pre>
  
  <p>Part My Fragment class :</p>
  
  <pre><code>//The button where it's called:
  @Override
      public void onMenuItemClicked(final int position) {
          mOptionsMenuHelper.hideMenu();
          menuButton.setSelected(false);
          switch (position) {
  
          case OptionMenuItems.EMAIL_STORY_POSITION:
              emailArticle();
              break;
          }
      }
  
  private void emailArticle() {
          final Fragment fragment =  mArticleAdapter.getFragment(mArticlePager.getCurrentItem());
  
          if (fragment instanceof ArticleFragmentWebView)  {
              final String emailSubject = ((ArticleFragmentWebView)fragment).getHeadline();
              final String articleBody  = ((ArticleFragmentWebView)fragment).getArticleBody();
              final String newLine = getResources().getString(R.string.new_line);
              final String disclamer = getResources().getString(R.string.intellectual_property_info);
              final String emailBody = articleBody + newLine + disclamer;
              EmailUtils.shareNewsViaEmail(this, emailSubject, emailBody);
          }
      }
  </code></pre>
  
  <p>How do I go about the same?</p>
  
  <p>Thanks!
  Here's the articlefragmentwebview:</p>
  
  <pre><code>public class ArticleFragmentWebView extends AbsBaseArticleFragment {
      public static final String TAG_ARTICLE_FRAGMENT = "ArticleFragment";
      public static final String ARTICLE_POSITION = "article_position";
      public static final String CATEGORY_CODE = "article_code";
      private int mPositionInPager;
      private ArticleWebViewClient articleWebViewClient;
  
      @Override
      public void onActivityCreated(final Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          mPositionInPager = getArguments().getInt(ARTICLE_POSITION);
      }
  
      @Override
      public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
          final View view = super.onCreateView(inflater, container, savedInstanceState);
          articleWebViewClient = new TechnicArticleWebViewClient(getActivity(), view);
          return view;
      }
  
      @Override
      public void onLoading() {
              final View fragmentView = getView();
              if (fragmentView != null) {
                  LayoutUtils.showLoading(fragmentView, "");
              }
      }   
      @Override
      public void showLoading(View view) {
              LayoutUtils.showLoading(view, "");
      }
      @Override
      public void showResults(final Uri uri) {
              LayoutUtils.showResults(getView(), R.id.news_body);
      }   
      @Override
      public void setTextSize(TextSize textSize) {
          articleWebViewClient.increaseFontSize();
      }
      @Override
      public void showNoResults(final Uri uri) {
      //  LayoutUtils.showNoResult(getView(), R.id.details_container);
      }
      @Override
      public void showRelatedDivider() {
  
      }
      @Override
      protected void getRelatedQuotes() {
  
      }
      @Override
      public Uri onCreateContentUri() {
          final String articleCode = getArguments().getString(ARTICLE_CODE);
          return Uri.withAppendedPath(NewsContentProvider.ARTICLE_MYNEWS_URI, articleCode);
      }
  
  
  
  
      @Override
      public void onStart() {
          super.onStart();
      }
  
      public int getPositionInPager() {
          return mPositionInPager;
      }
  
      @Override
      protected int getFragmentLayoutId() {
          return R.layout.fragment_article_briefcase;
      }
  
      @Override
      protected int getArticleTextViewId() {
          return R.id.news_body;
      }
  
      @Override
      protected int getFlowTextViewId() {
          return R.id.tv;
      }
  
      @Override
      protected int getHeaderTextViewId() {
          return R.id.headline;
      }
  
      @Override
      protected int getMetadataTextViewId() {
          return R.id.timestamp_and_source;
      }
  
      @Override
      public void onMenuItemClicked(final int position) {
          //Do nothing
      }
      @Override
      public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
          if (view.getId() !=  R.id.news_body)            // paranoia
              return true;
  
          String article = cursor.getString(columnIndex);
          String storyId = cursor.getString(cursor.getColumnIndex(Briefcase.Columns.ID));
          return articleWebViewClient.setArticle(article, storyId);
      }
  }
  </code></pre>
  
  <p>and here's the model class for getarticlebody:</p>
  
  <pre><code>public class Briefcase {
  
  
          public static final String TEXT_TYPE = "TEXT";
          public static final String HTML_TYPE = "Html";
          public static final String PDF_TYPE = "PDF";
  
      public static class Columns {
  
          public static final String ID = "Id";
          public static final String NAME = "Name";
          public static final String SAVED_DATE = "SavedDate";
          public static final String TYPE = "DocumentType";
          public static final String DOCUMENT_DATE = "DocumentDate";
          public static final String SOURCE = "DocumentSource";
          public static final String DOCUMENT_LINK = "DocumentLink";
          public static final String DOCUMENT_ID = "DocumentId";
          public static final String IS_READ = "IsRead";
          public static final String ARTICLE_BODY = "ArticleBody";
          //PrimaryRic
      }
  
      public Briefcase(String id, String articleId, String name, String docDate, String source, String docType){
          mId = id;
          mDocumentId = articleId;
          mName = name;
          mPNACDate = docDate;
          mDocumentSource = source;
          mDocumentType = docType;
          mIsRead = "false";
          mSavedDate = new Date();
      }
  
      @SerializedName(Columns.ID)
      private String mId;
  
      @SerializedName(Columns.NAME)
      private String mName;
  
      @SerializedName(Columns.SAVED_DATE)
      private Date mSavedDate;
  
      @SerializedName(Columns.TYPE)
      private String mDocumentType;
  
      @SerializedName(Columns.DOCUMENT_DATE)
      private String mPNACDate;
  
      @SerializedName(Columns.SOURCE)
      private String mDocumentSource;
  
      @SerializedName(Columns.DOCUMENT_ID)
      private String mDocumentId;
  
      @SerializedName(Columns.IS_READ)
      private String mIsRead;
  
      public String getId() {
          return mId;
      }
  
      public String getName() {
          return mName;
      }
  
      public Date getSavedDate() {
          return mSavedDate;
      }
  
      public String getDocumentType() {
          return mDocumentType;
      }
  
      public String getPNACDate() {
          return mPNACDate;
      }
  
      public String getDocumentSource() {
          return mDocumentSource;
      }
  
      public String getDocumentLink() {
          String docLink = null;
          if(StringUtils.isEmpty(mDocumentSource))
              return docLink;
  
          return mDocumentId;
  
      }
  
      public String getIsRead() {
          return mIsRead;
      }
  
      public ContentValues toContentValues() {
          if (hasValidData()) {
              final ContentValues values = new ContentValues();
              values.put(Columns.ID, mId);
              values.put(Columns.NAME, decodeHeadline());
              values.put(Columns.SAVED_DATE, mSavedDate.getTime());
              values.put(Columns.DOCUMENT_LINK, getDocumentLink());
              values.put(Columns.DOCUMENT_DATE, DateUtils.convertFromUTCStringToLong(mPNACDate));
              values.put(Columns.SOURCE, mDocumentSource);
              values.put(Columns.IS_READ, mIsRead);
              values.put(Columns.TYPE, mDocumentType);
              values.put(GenericColumns.USER_ID, SharedPreferencesManager.getInstance().getLoginUsername());
              return values;
          }
          return null;
      }
  
      private String decodeHeadline() {
          String decodedHeadline = mName;
          try {
              decodedHeadline = URLDecoder.decode(mName, NetworkUtils.Values.UTF_8);
          } catch (final Exception e) {
              e.printStackTrace();
          }
          return decodedHeadline;
      }
  
      public ContentValues toContentForDatabaseUpdateValues() {
          if (hasValidData()) {
              final ContentValues values = toContentValues();
              values.put(Columns.ARTICLE_BODY, getArticleBody());
              return values;
          }
          return null;
      }
  
      private String getArticleBody() {
          String body = "";
          final ContentResolver resolver = Application.getAppContext().getContentResolver();
          final String[] projection = new String [] {Columns.ARTICLE_BODY};
          final Uri uri = Uri.withAppendedPath(BriefcaseContentProvider.BRIEFCASE_ARTICLE_STORY_URI, mId);
          final Cursor cursor = resolver.query(uri, projection, null, null, null);
          if(cursor.getCount()&gt;0){
              cursor.moveToFirst();
              body = cursor.getString(cursor.getColumnIndex(Columns.ARTICLE_BODY));
          }
          return body;
      }
  
      private boolean hasValidData() {
          boolean isValid = false;
          if (StringUtils.isNotEmpty(mId) &amp;&amp; StringUtils.isNotEmpty(mName)){
              isValid = true;
          }
          return isValid;
      }
  
  }
  </code></pre>