Android 安卓:api 2级和5级在发送操作上有什么不同?
我有一个android应用程序,想启动一封电子邮件。以下代码在api 5级仿真器中工作,但不在2级仿真器或设备上工作:Android 安卓:api 2级和5级在发送操作上有什么不同?,android,android-emulator,Android,Android Emulator,我有一个android应用程序,想启动一封电子邮件。以下代码在api 5级仿真器中工作,但不在2级仿真器或设备上工作: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Email from MyApp"); emailIntent.setType("text/plain"); emailI
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Email from MyApp");
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"This email was autogenerated by MyApp.");
try {
startActivity(emailIntent);
} catch (Exception e) {
Log.e(TAG,e.getMessage());
showDialog(DIALOG_CANTSENDMAIL);
}
抛出的异常表示:
No Activity found to handle Intent { action=android.intent.action.SEND (has extras) }
我可以从所有模拟和实际测试的设备手动发送电子邮件,这在5级api中工作。Intent.ACTION\u SEND的文档中说,它从API级别1开始就一直处于活动状态。我认为区别可能不在于API,而在于系统上可用的应用程序。在Android 1.1和1.5中,电子邮件应用程序尤其有限,因此如果它无法处理ACTION\u SEND,我也不会感到惊讶
也可能是,如果您配置了Gmail应用程序,同样的操作也会起作用,但与emulator中的电子邮件应用程序不同。请注意,按照0.3%的比例,实际上没有使用2级API设备。