2012-01-20 137 views
0

編輯:解決方案Hiren給工作。非常感謝!對於那些有類似問題的人,請按照以下說明進行操作:Android Honeycomb: NetworkOnMainThreadException even when using AsyncTask and no strict mode?無法通過android 3.2上的javamail API發送電子郵件

再次感謝!

我正在爲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) 
+0

請發佈堆棧跟蹤。 – CommonsWare

+0

這不是一個堆棧跟蹤。 – CommonsWare

+0

道歉我今天沒有醒過來!我會再次編輯 - 這可能會提供儘可能多的信息。 –

回答

0

嘗試 this鏈接,我用我的應用程序相同的鏈接,它適用於我。其他link使用smtp(gmail)

+0

非常感謝它現在的作品:) –

相關問題