如何检测是否通过Android中的应用程序发送电子邮件?

时间:2012-04-18 08:01:34

标签: android

我已经从我的应用程序启动了电子邮件活动..我的问题是我怎么知道是否发送电子邮件

try {

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/html"); 
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Check out this play from http://www.iplaybook.net iPlayBook ");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"This play was created using<a href='http://www.iplaybook.net'> iPlayBook.</a>");
    final PackageManager pm = getPackageManager();
    @SuppressWarnings("static-access")
    final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, pm.MATCH_DEFAULT_ONLY);
    ResolveInfo best = null;
    for (final ResolveInfo info : matches)
    {
        if (info.activityInfo.name.toLowerCase().contains("mail"))
            best = info;
    }
    if (best != null)
    {
        emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name);
        startActivit(emailIntent);
    }
}
catch(Exception e) { }

}

plz help ..

1 个答案:

答案 0 :(得分:0)

您无法从Android确认电子邮件是否已发送。实际发送电子邮件是异步设计,因此活动可能会在实际发送电子邮件之前返回。

Please search the questions in SO before posting a new one

干杯, RJ