下面的代码是我目前正在使用的列表视图项,以便当我点击它,电子邮件编写器启动。然而,在发送一条信息后,它不会带我回到我的应用程序。我怎么才能让它回到我的应用程序后,发送电子邮件?如果有人有更好的方法做这件事,请告诉我。
所有的帮助都是感激的。
if(position == 7) {
Log.i("Send email", "");
String[] TO = {"person@gmail.com"};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:person@gmail.com"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
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();
}
}发布于 2014-09-11 17:05:34
应用程序退出,因为在try{.}中调用的finish()方法将在执行之前的代码之后立即停止该活动。删除或注释finish()方法来解决这个问题。
https://stackoverflow.com/questions/25791792
复制相似问题