为了通过设备的默认 Gmail 意图发送邮件,我正在使用以下功能:
private void initShareIntent(String type) {
boolean found = false;
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// gets the list of intents that can be loaded.
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(
share, 0);
if (!resInfo.isEmpty()) {
for (ResolveInfo info : resInfo) {
if (info.activityInfo.packageName.toLowerCase().contains(type)
|| info.activityInfo.name.toLowerCase().contains(type)) {
share.putExtra(Intent.EXTRA_SUBJECT,
"Reg:xxx");
share.putExtra(Intent.EXTRA_TEXT, shareText);
share.setPackage(info.activityInfo.packageName);
found = true;
break;
}
}
if (!found) {
return;
}
startActivity(Intent.createChooser(share, "Select"));
}
}
并像这样调用函数:
initShareIntent("mail");
有没有办法获得这个动作的发送状态(成功或失败)?
提前致谢