0

编辑: Hiren 给出的解决方案奏效了。非常感谢!对于那些有类似问题的人,请按照这些说明进行操作并查看以下内容:Android Honeycomb: NetworkOnMainThreadException even when using AsyncTask and no strict mode?

再次感谢!

我正在为 Galaxy 选项卡开发应用程序,但无法从该选项卡发送电子邮件。我发现的代码可以在其他地方(包括我的手机)使用,但确实可以not work on the tab

当我尝试通过 javamail 发送邮件时遇到的异常是这样的:

不加载file: /system/lib/javamail.providers

我尝试使用下面建议的解决方案,但出现以下异常:

01-21 14:30:14.340: E/MailApp(3515): Could not send email
01-21 14:30:14.340: E/MailApp(3515): android.os.NetworkOnMainThreadException
01-21 14:30:14.340: E/MailApp(3515):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
01-21 14:30:14.340: E/MailApp(3515):    at java.net.InetAddress.lookupHostByName(InetAddress.java:477)
01-21 14:30:14.340: E/MailApp(3515):    at java.net.InetAddress.getLocalHost(InetAddress.java:445)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.internet.InternetAddress.getLocalAddress(InternetAddress.java:517)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.internet.UniqueValue.getUniqueMessageIDValue(UniqueValue.java:99)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.internet.MimeMessage.updateMessageID(MimeMessage.java:2054)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2076)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)
01-21 14:30:14.340: E/MailApp(3515):    at javax.mail.Transport.send(Transport.java:117)
01-21 14:30:14.340: E/MailApp(3515):    at android.app.Mail.send(Mail.java:136)
01-21 14:30:14.340: E/MailApp(3515):    at android.app.ConfirmationActivity.onSubmit(ConfirmationActivity.java:151)
01-21 14:30:14.340: E/MailApp(3515):    at java.lang.reflect.Method.invokeNative(Native Method)
01-21 14:30:14.340: E/MailApp(3515):    at java.lang.reflect.Method.invoke(Method.java:491)
01-21 14:30:14.340: E/MailApp(3515):    at android.view.View$1.onClick(View.java:2695)
01-21 14:30:14.340: E/MailApp(3515):    at android.view.View.performClick(View.java:3127)
01-21 14:30:14.340: E/MailApp(3515):    at android.view.View$PerformClick.run(View.java:12025)
01-21 14:30:14.340: E/MailApp(3515):    at android.os.Handler.handleCallback(Handler.java:587)
01-21 14:30:14.340: E/MailApp(3515):    at android.os.Handler.dispatchMessage(Handler.java:92)
01-21 14:30:14.340: E/MailApp(3515):    at android.os.Looper.loop(Looper.java:132)
01-21 14:30:14.340: E/MailApp(3515):    at android.app.ActivityThread.main(ActivityThread.java:4126)
01-21 14:30:14.340: E/MailApp(3515):    at java.lang.reflect.Method.invokeNative(Native Method)
01-21 14:30:14.340: E/MailApp(3515):    at java.lang.reflect.Method.invoke(Method.java:491)
01-21 14:30:14.340: E/MailApp(3515):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
01-21 14:30:14.340: E/MailApp(3515):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
01-21 14:30:14.340: E/MailApp(3515):    at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

0

试试这个链接,我为我的应用程序使用了相同的链接,它对我来说很好。使用 smtp(gmail) 的其他链接

于 2012-01-21T04:39:57.680 回答