我通过我的应用程序发送邮件已发送邮件,但附带的文本不随其一起发送。
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..."));
}
});
}
}
从此应用程序用户可以共享链接,虽然邮件是从它发送但文本是空的
答案 0 :(得分:1)
问题是你在做什么
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText());
当你应该调用toString()时,它将会是:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText().toString());