0

EDIT: The solution Hiren gave worked. Thank you so much!For those that are having similar issues, follow these instructions and also look at this: Android Honeycomb: NetworkOnMainThreadException even when using AsyncTask and no strict mode?

Thanks once again!

I'm developing an app for the galaxy tab and I am unable to send emails from the tab. The code I've found works elsewhere (including my phone) but it does not work on the tab.

The exception I get when I try to send mails through javamail is something like this:

not loading file: /system/lib/javamail.providers

I tried to use the solution suggested below and I got the following exception:

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)
Community
  • 1
  • 1
Yusuf Hoque
  • 421
  • 4
  • 8
  • Apologies I'm not awake today! I'll edit again - this will probably be as much info as I can give. – Yusuf Hoque Jan 21 '12 at 00:54
  • That is indeed a stack trace. It would not appear to have anything to do with JavaMail. Perhaps you should consider contacting the people who created the Android JavaMail port for assistance, maybe by filing an issue with a sample project that demonstrates your problem: http://code.google.com/p/javamail-android/ – CommonsWare Jan 21 '12 at 01:05
  • You're right, Java mail is fine as it works perfectly on my phone. I'm just confused as to why the same code does not work on the galaxy tab. Oh well appreciate the help - hopefully I can get a solution to this quick.. Good night! – Yusuf Hoque Jan 21 '12 at 01:21

1 Answers1

0

try this link, i have used the same link for my application and it works fine for me. other link using smtp(gmail)

Hiren Dabhi
  • 3,555
  • 5
  • 32
  • 58