在我的android应用程序有一个按钮发送邮件,当我点击发送按钮使用这行Gmail将打开,然后我点击发送邮件。为什么邮件会在我的应用程序关闭的同时成功发送?我需要留在同一页面?当我调用intent.createChooser发送邮件时自动关闭应用程序?
try
{
String extpath=Environment.getExternalStorageDirectory() +"/NewFolder/DBName";
File pathp=new File(extpath);
Log.d("New Path", pathp.toString());
long fileSize = pathp.length();
if(fileSize > 0)
{
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String address = "[email protected]";
String subject = "Database";
String emailtext = "Please check the attached database and save it";
emailIntent.setType("application/octet-stream");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { address });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + pathp));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext);
startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
}
else
{
Log.d("Error", "Attachment didn't attach ");
}
}
catch (Throwable t)
{
Log.d("Error on sending mail", t.toString());
}
当我运行此代码邮件发送,然后应用程序将关闭。我不想关闭应用程序。提前帮助我感谢。
发布了一些相关的代码 – kgandroid 2014-09-19 12:15:47
@kgandroid我更新了我的问题,好心的读了它 – Sri 2014-09-19 12:23:53
@Sri你有什么错误? – 2014-09-19 12:34:51