我的代码存在问题,但是用户放了他的电子邮件后我想要我发送“发送邮件按钮”,它会将邮件发送给用户输入。
@Override
public void onClick(View v) {
if (btnMail == v) {
Intent intent=getIntent();
String mail = intent.getExtras().getString("Mail");
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("text/plain");
email.putExtra(Intent.EXTRA_EMAIL,mail);
email.putExtra(Intent.EXTRA_SUBJECT, "invite from my app");
email.putExtra(Intent.EXTRA_TEXT, "this my new app");
startActivity(Intent.createChooser(email, "Send Email"));
}
else if (btnAdress==v){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("geo:19.076,72.8777"));
Intent chooser=Intent.createChooser(intent,"Launch Map");
startActivity(chooser);
}
}
@Override
public void onClick(View v) {
if (btSand==v) {
Intent intent = new Intent(MainActivity.this, Main2Activity2.class);
intent.putExtra("name",etName.getText().toString());
intent.putExtra("Mail",etMail.getText().toString());
startActivity(intent);
}
}
答案 0 :(得分:0)
好的,我设法找到答案
如果somone想要它:
@Override
public void onClick(View v) {
if (btnMail == v) {
String []emails = {MainActivity.SendMail};
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("text/plain");
email.putExtra(Intent.EXTRA_EMAIL,emails);
email.putExtra(Intent.EXTRA_SUBJECT, "invite from my app");
email.putExtra(Intent.EXTRA_TEXT, "this my new app");
startActivity(Intent.createChooser(email, "Send Email"));