ここで以前のスタックオーバーフローの回答のコードを使用しています
Android 2.2、2.3で完全に機能しています
しかし、4.1 以降では動作しません。修正方法を教えてください。
エラーレポート
08-19 16:18:23.722: E/SEND(17510): ERROR
08-19 16:18:23.722: E/SEND(17510): android.os.NetworkOnMainThreadException
08-19 16:18:23.722: E/SEND(17510): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-19 16:18:23.722: E/SEND(17510): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
08-19 16:18:23.722: E/SEND(17510): at java.net.InetAddress.getLocalHost(InetAddress.java:365)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.internet.InternetAddress.getLocalAddress(InternetAddress.java:517)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.internet.UniqueValue.getUniqueMessageIDValue(UniqueValue.java:99)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.internet.MimeMessage.updateMessageID(MimeMessage.java:2054)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2076)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)
08-19 16:18:23.722: E/SEND(17510): at javax.mail.Transport.send(Transport.java:117)
08-19 16:18:23.722: E/SEND(17510): at hai.bt.expensemanager.Mail.send(Mail.java:77)
08-19 16:18:23.722: E/SEND(17510): at hai.bt.expensemanager.ForgotPasswordActivity$2.onClick(ForgotPasswordActivity.java:79)
08-19 16:18:23.722: E/SEND(17510): at android.view.View.performClick(View.java:4084)
08-19 16:18:23.722: E/SEND(17510): at android.view.View$PerformClick.run(View.java:16966)
08-19 16:18:23.722: E/SEND(17510): at android.os.Handler.handleCallback(Handler.java:615)
08-19 16:18:23.722: E/SEND(17510): at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 16:18:23.722: E/SEND(17510): at android.os.Looper.loop(Looper.java:137)
08-19 16:18:23.722: E/SEND(17510): at android.app.ActivityThread.main(ActivityThread.java:4874)
08-19 16:18:23.722: E/SEND(17510): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 16:18:23.722: E/SEND(17510): at java.lang.reflect.Method.invoke(Method.java:511)
08-19 16:18:23.722: E/SEND(17510): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
08-19 16:18:23.722: E/SEND(17510): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
08-19 16:18:23.722: E/SEND(17510): at dalvik.system.NativeStart.main(Native Method)