Reputation: 111
I am sending mail through my application mail is sent but the attached text is not sent with it.
public class Email extends Activity {
Button send;
EditText address, subject, emailtext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share);
send=(Button) findViewById(R.id.btnsubmitShare);
address=(EditText) findViewById(R.id.edittexttoShare);
subject=(EditText) findViewById(R.id.edittextsubjectShare);
send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/octet-stream");
// final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ address.getText().toString()});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText());
// emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText());
Email.this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
});
}
}
From this application user can share a link, although mail is sent from it but text is empty
Upvotes: 1
Views: 418
Reputation: 7082
The problem is you are doing
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText());
when you should make a call to toString(), so it's going to be:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString());
Upvotes: 1