1

我的应用程序通过意图发送电子邮件并且工作得很好。问题是,在第一封电子邮件之后,我无法发送更多电子邮件,因为 gMail(在这种情况下)虽然它似乎工作得很好,但没有发送任何内容,因为我认为它仍然在后台打开。所以,我必须关闭我的应用程序,使用任务杀手杀死所有进程(从而杀死 Gmail)并重新启动。有没有办法在发送第一封电子邮件后关闭电子邮件客户端?

谢谢。

编辑:

这是意图:

private void shareIntent(String string) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
saveDir=("/Scorepad/.temp");
        if (string=="png" ) {
        exportToBmpHandler("Shared_Image", saveDir);// here create and     save the bitmap
        sharingIntent.setType("image/png");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Scorepad/.temp/Shared_Image.png")); 
        }
        else {
            try {
            exportPdf("Shared_Pdf", saveDir+"/"); // here create and save the pdf
            } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            sharingIntent.setType("image/pdf");
            sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Scorepad/.temp/Shared_Pdf.pdf")); }
try {
startActivityForResult(Intent.createChooser(sharingIntent, "Share image using"), EMAIL);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getBaseContext(),"There are no email clients installed.", Toast.LENGTH_SHORT).show();

} finally {}
}

这是 Activity onResult:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == PICK_PROJECT_FILE && resultCode == Activity.RESULT_OK) {
// .................
}

if (requestCode == CREATE_CHORDS && resultCode == Activity.RESULT_OK) {
// .............
}

if(requestCode==EMAIL && resultCode==Activity.RESULT_OK){ 
Toast.makeText(this, "Mail sent.", Toast.LENGTH_SHORT).show();}
/*  if (requestCode==EMAIL && resultCode==Activity.RESULT_CANCELED)
{ Toast.makeText(this, "Mail canceled.", Toast.LENGTH_SHORT).show();} */

super.onActivityResult(requestCode, resultCode, data);
}
4

1 回答 1

0

I just figured out, Gmail sort of only sends an email which has either different subject, content, attachment or cc/bcc than the last email sent within several minutes.

于 2014-02-03T22:41:33.397 回答