简体   繁体   English

Android JavaMail,无法使用 IMAP 获取 email

[英]Android JavaMail, can't get email with IMAP

I am trying to write email app on Android.我正在尝试在 Android 上编写 email 应用程序。 I have found this question and tried to use check method on my application, but I always get我发现了这个问题并尝试在我的应用程序上使用检查方法,但我总是得到

W/System: ClassLoader referenced unknown path: /data/app/com.example.mailappjava-2/lib/x86
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
D/: HostConnection::get() New Host Connection established 0xaa3611c0, tid 7129
D/: HostConnection::get() New Host Connection established 0xaa361740, tid 7160
I/OpenGLRenderer: Initialized EGL, version 1.4
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation: eglCreateContext: 0xae594600: maj 3 min 1 rcv 4
D/EGL_emulation: eglMakeCurrent: 0xae594600: ver 3 1 (tinfo 0xae592b50)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
    glUtilsParamSize: unknow param 0x00008cdf
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
D/EGL_emulation: eglMakeCurrent: 0xae594600: ver 3 1 (tinfo 0xae592b50)
W/System.err: android.os.NetworkOnMainThreadException
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
        at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
        at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
        at java.net.InetAddress.getByName(InetAddress.java:305)
        at java.net.InetSocketAddress.<init>(InetSocketAddress.java:100)
        at java.net.InetSocketAddress.<init>(InetSocketAddress.java:85)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
        at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
        at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
        at javax.mail.Service.connect(Service.java:288)
        at javax.mail.Service.connect(Service.java:169)
        at com.example.mailappjava.JavaMailAPIretrevial.check(JavaMailAPIretrevial.java:47)
        at com.example.mailappjava.ui.home.HomeFragment.onClick(HomeFragment.java:55)
        at android.view.View.performClick(View.java:5198)
        at android.view.View$PerformClick.run(View.java:21147)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I would be very grateful for your help我将非常感谢您的帮助

Pass your exception log: android.os.NetworkOnMainThreadException传递您的异常日志: android.os.NetworkOnMainThreadException

You cannot go to the network request in the main thread.您不能 go 到主线程中的网络请求。

Can you provide the code of the place where the mail is requested?能否提供寄件地址的代码?


    public void onClick(View v){
        new Thread(new Runnable() {
            @Override
            public void run() {
                JavaMailAPIretrevial recieve = new JavaMailAPIretrevial(fragment_context);
            }
        }).start();

    }

To anyone that may be in the same situation as I was.对于任何可能与我处于相同情况的人。 I couldn't find any tutorial about how to implement an Inbox on Android, but after some research on Github, I found a nice repository for both sending and getting emails.我找不到任何关于如何在 Android 上实现收件箱的教程,但是在对 Github 进行了一些研究之后,我找到了一个很好的用于发送和接收电子邮件的存储库。 If you are stuck as I was, check this repo for reference: https://github.com/Sunghee2/Email-android如果您像我一样被卡住,请查看此存储库以供参考: https://github.com/Sunghee2/Email-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM