我打算使用android studio开发一个android移动应用程序,用户在其中提供电子邮件地址和密码。然后,应该将该密码发送到提到的电子邮件地址。任何机构都可以共享任何代码段以执行此操作吗?
如果您想在后台发送电子邮件,请点击此处
如果用户正在屏幕上等待,请使用以下方法:
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {"[email protected]"};
String[] CC = {"[email protected]"};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this,
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句