此类在 ICS 上运行良好,但ActivityNotFoundException
在 Jelly Bean 上失败。你们知道为什么吗?谢谢你。
public class EmailSender {
public static Intent getSendEmailIntent(Context context, String email,
String subject, String body, File fileName, String chooserTitle) {
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
//Explicitly only use Gmail to send
emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
emailIntent.setType("plain/text");
//Add the recipients
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{email});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
//Add the attachment by specifying a reference to our custom ContentProvider
//and the specific file of interest
emailIntent.putExtra(
Intent.EXTRA_STREAM,
Uri.fromFile(fileName));
return emailIntent;
}
}
在果冻豆上,我遇到了一个例外:
11-19 15:32:07.852: E/AndroidRuntime(19630): android.content.ActivityNotFoundException: 找不到明确的活动类 {com.google.android.gm/com.google.android.gm.ComposeActivityGmail}; 您是否在 AndroidManifest.xml 中声明了此活动?
如有需要,可全程跟踪:
11-19 15:32:07.852: E/AndroidRuntime(19630): android.content.ActivityNotFoundException: 找不到明确的活动类 {com.google.android.gm/com.google.android.gm.ComposeActivityGmail}; 您是否在 AndroidManifest.xml 中声明了此活动?11-19 15:32:07.852: E/AndroidRuntime(19630): 在 android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618) 11-19 15:32:07.852: E/AndroidRuntime(19630): 在 android. app.Instrumentation.execStartActivity(Instrumentation.java:1417) 11-19 15:32:07.852: E/AndroidRuntime(19630): 在 android.app.Activity.startActivityForResult(Activity.java:3370) 11-19 15:32: 07.852: E/AndroidRuntime(19630): 在 android.app.Activity.startActivityForResult(Activity.java:3331) 11-19 15:32:07.852: E/AndroidRuntime(19630): 在 android.support.v4.app.FragmentActivity .