gpt4 book ai didi

java - 将邮件输入移至邮件应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 11:58:32 30 4
gpt4 key购买 nike

在用户输入我想要的电子邮件后,我的代码出现问题,在我按下“发送邮件按钮”后,它会将邮件发送到用户输入。

@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);
}
}

first activity

@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);
}
}

seconf activity

最佳答案

好吧,我设法找到答案

如果有人想要它:

    @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"));

关于java - 将邮件输入移至邮件应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41130850/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com