问题描述
我写在我试图用一些数据发送电子邮件的应用程序,但每当我点击就提交按钮发送一封电子邮件,的使用的不幸的是应用程序已停止
错误:
android.content.ActivityNotFoundException:无活动处理意向{行动= android.intent.action.SEND典型值= text / plain的(有临时演员)}
code:
意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
emailIntent.setType(text / plain的);
字符串aEmailList [] = {[email protected]};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,学科);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body.toString()));
startActivity(emailIntent);
logcat的:
8月8日至1日:34:22.518:E / AndroidRuntime(1043):致命异常:主要
8月8日至1日:34:22.518:E / AndroidRuntime(1043):android.content.ActivityNotFoundException:无活动来处理意图行事{= android.intent.action.SENDTO典型值= text / plain的(有临时演员)}
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Activity.startActivityForResult(Activity.java:3370)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Activity.startActivityForResult(Activity.java:3331)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Activity.startActivity(Activity.java:3566)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.Activity.startActivity(Activity.java:3534)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在app.my.BookAppointmentActivity $ 6.onClick(BookAppointmentActivity.java:206)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.view.View.performClick(View.java:4204)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.view.View $ PerformClick.run(View.java:17355)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.os.Handler.handleCallback(Handler.java:725)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.os.Handler.dispatchMessage(Handler.java:92)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.os.Looper.loop(Looper.java:137)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在android.app.ActivityThread.main(ActivityThread.java:5041)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在java.lang.reflect.Method.invokeNative(本机方法)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在java.lang.reflect.Method.invoke(Method.java:511)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
8月8日至1日:34:22.518:E / AndroidRuntime(1043):在dalvik.system.NativeStart.main(本机方法)
几个月前,我正面临着同样的问题,我发现了一个小的解决方案,请尝试以下code。通过更换你的
意向书I =新意图(Intent.ACTION_SEND);
i.setType(纯/文);
i.putExtra(Intent.EXTRA_EMAIL,新的String [] {[email protected]});
i.putExtra(Intent.EXTRA_SUBJECT,学科);
i.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(body.toString()));
尝试{
startActivity(ⅰ);
}赶上(android.content.ActivityNotFoundException前){
Toast.makeText(Activity.this,有没有安装的电子邮件应用程序,Toast.LENGTH_SHORT).show();
}
}
如果您将获得有没有安装电子邮件应用程序。的消息,这意味着你的工作就完成了,我会建议你检查它在真实的设备,但我也不知道如何通过仿真器发送
I am writing an app in which i am trying to send an email with some data, but whenever i do click on Submit button to send an email, getting : Unfortunately App has Stopped
Error:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/plain (has extras) }
Code:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
String aEmailList[] = { "[email protected]" };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body.toString()));
startActivity(emailIntent);
Logcat:
08-01 08:34:22.518: E/AndroidRuntime(1043): FATAL EXCEPTION: main
08-01 08:34:22.518: E/AndroidRuntime(1043): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO typ=text/plain (has extras) }
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Activity.startActivityForResult(Activity.java:3370)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Activity.startActivityForResult(Activity.java:3331)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Activity.startActivity(Activity.java:3566)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.Activity.startActivity(Activity.java:3534)
08-01 08:34:22.518: E/AndroidRuntime(1043): at app.my.BookAppointmentActivity$6.onClick(BookAppointmentActivity.java:206)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.view.View.performClick(View.java:4204)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.view.View$PerformClick.run(View.java:17355)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.os.Handler.handleCallback(Handler.java:725)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.os.Handler.dispatchMessage(Handler.java:92)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.os.Looper.loop(Looper.java:137)
08-01 08:34:22.518: E/AndroidRuntime(1043): at android.app.ActivityThread.main(ActivityThread.java:5041)
08-01 08:34:22.518: E/AndroidRuntime(1043): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 08:34:22.518: E/AndroidRuntime(1043): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 08:34:22.518: E/AndroidRuntime(1043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-01 08:34:22.518: E/AndroidRuntime(1043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-01 08:34:22.518: E/AndroidRuntime(1043): at dalvik.system.NativeStart.main(Native Method)
Few months ago i was facing same problem, and i found a small solution, please try below code by replacing yours
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("plain/text");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT, subject);
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body.toString()));
try {
startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show();
}
}
If you will get There are no email applications installed. message, it means your work is done and i will suggest you to check it on real DEVICE, but i also don't know how to send it via EMULATOR
这篇关于android.content.ActivityNotFoundException使用意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!