title: Pass info from edittext through an email intent
body: <p>I have two textboxes: one for the subject and the other for the actual message. Unfortunately, the code I'm using does not pass any information when I test it on my phone running android 4.2.2 with the latest gmail app. </p>
  
  <p>Updated method.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  setContentView(R.layout.tipus);
  findViewById(R.id.sendemailbutton).setOnClickListener(emailclick);
  findViewById(R.id.cancelbtn).setOnClickListener(myclick);
  subjectline = (EditText) findViewById(R.layout.tipus);
  emailcontent = (EditText) findViewById(R.layout.tipus);
  
  }
  
  public final Button.OnClickListener emailclick = new Button.OnClickListener() {
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);  
  
          String aEmailList[] = { oliuremail, vikemail };   
          emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);  //supposed to pass info of the emails to the email app
          emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subjectline.getText().toString());  //not taking stuff from an edittext, only things in quotes. 
          emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailcontent.getText().toString());  //won't accept anything from an edittext.
          emailIntent.setType("plain/text");
          startActivity(Intent.createChooser(emailIntent, "Send Email Using...")); 
      }
  
  };
  </code></pre>
  
  <p>tipus.xml (Updated)</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;TextView
      android:id="@+id/messagetitle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/emailmessage"
      android:layout_alignParentLeft="true"
      android:layout_marginBottom="46dp"
      android:text="Message:" /&gt;
  
  &lt;EditText
      android:id="@+id/emailmessage"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:layout_marginBottom="122dp"
      android:ems="10"
      android:hint="Write your message here."
      android:inputType="textMultiLine" /&gt;
  
  &lt;Button
      android:id="@+id/cancelbtn"
      style="?android:attr/buttonStyleSmall"
      android:layout_width="30dp"
      android:layout_height="30dp"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:background="@drawable/arrowrightblack" /&gt;
  
  &lt;Button
      android:id="@+id/sendemailbutton"
      style="?android:attr/buttonStyleSmall"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:text="Send" /&gt;
  
  &lt;EditText
      android:id="@+id/subjectline"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/subjectdenoter"
      android:layout_alignBottom="@+id/subjectdenoter"
      android:layout_alignParentRight="true"
      android:ems="10"
      android:hint="Please Add a Subject." /&gt;
  
  &lt;TextView
      android:id="@+id/subjecttitle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/textView3"
      android:layout_alignRight="@+id/textView3"
      android:layout_marginBottom="82dp"
      android:text="Subject:" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I use this code, the info gets passed to the email app. However, I have two textboxes in which the user will type in a subject and then type in the actual text of the email. I need the info passed from the two text boxes to be sent to the email app. I've looked over stackoverflow and tutsplus and they had some info but the ones that talked about passing data from textboxes were not very informative. Thanks in advance. </p>
  
  <p>EDIT:</p>
  
  <p>I finally found out the answer. You must make a private string such as:</p>
  
  <pre><code>private String getSubjectContent() {
      String text = "";
  
      text += yourtexteditname.getText().toString() + "\n";
  
      return text;
  }
  </code></pre>
  
  <p>NOTE: You can make as many of these methods in the class. In each method, just replace "yourtexteditname" with the name of the textEdit. You can also put multiple textEdits into one method if you want to get info from multiple textEdits and put them into one place in the email (Subject line, message body etc.)</p>
  
  <p>Then, all you have to do is add the normal code to start an intent. Like this:</p>
  
  <pre><code>public final Button.OnClickListener emailclick = new Button.OnClickListener() {
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          variablename = (EditText) findViewById(R.id.textviewname); //defining the textedit you want to get info from. 
          variablename = (EditText) findViewById(R.id.othertextviewname); //defining the textEdit you want to get info from.
          Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
          emailIntent.setType("message/rfc822"); //specifies message for email app.
          emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getEmailContent()); //adds the actual content of the email by calling the method previously defined
          emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getSubjectContent()); //adds the subject by calling the method previously defined.
          startActivity(Intent.createChooser(emailIntent, "Title of the dialog chooser"));
  
  
      }
  
  };
  </code></pre>