在Android中发送电子邮件

在Android中发送电子邮件,android,Android,我正在尝试通过单击按钮发送电子邮件,发送的邮件是用户给定的标识码。但是电子邮件没有正确发送。谁能帮我解决这个问题 我根据以下内容创建了我的应用程序:- 这是我收到的日志信息 03-16 01:51:13.592 1913-1913/com.example.dushani.emailsender I/art﹕ Not late-enabling -Xcheck:jni (already on) 03-16 01:51:13.688 1913-1928/com.example.dush

我正在尝试通过单击按钮发送电子邮件,发送的邮件是用户给定的标识码。但是电子邮件没有正确发送。谁能帮我解决这个问题

我根据以下内容创建了我的应用程序:-

这是我收到的日志信息

03-16 01:51:13.592    1913-1913/com.example.dushani.emailsender I/art﹕ Not late-enabling -Xcheck:jni (already on)
03-16 01:51:13.688    1913-1928/com.example.dushani.emailsender D/OpenGLRenderer﹕ Render dirty regions requested: true
03-16 01:51:13.711    1913-1913/com.example.dushani.emailsender D/﹕ HostConnection::get() New Host Connection established 0xae2eadc0, tid 1913
03-16 01:51:13.724    1913-1913/com.example.dushani.emailsender D/Atlas﹕ Validating map...
03-16 01:51:13.750    1913-1925/com.example.dushani.emailsender I/art﹕ Background sticky concurrent mark sweep GC freed 1795(95KB) AllocSpace objects, 0(0B) LOS objects, 35% free, 402KB/623KB, paused 16.584ms total 23.060ms
03-16 01:51:13.909    1913-1928/com.example.dushani.emailsender D/﹕ HostConnection::get() New Host Connection established 0xa6e3f3f0, tid 1928
03-16 01:51:13.925    1913-1928/com.example.dushani.emailsender I/OpenGLRenderer﹕ Initialized EGL, version 1.4``
03-16 01:51:13.999    1913-1925/com.example.dushani.emailsender I/art﹕ Background partial concurrent mark sweep GC freed 1958(107KB) AllocSpace objects, 0(0B) LOS objects, 53% free, 436KB/948KB, paused 1.878ms total 189.812ms
03-16 01:51:14.019    1913-1928/com.example.dushani.emailsender D/OpenGLRenderer﹕ Enabling debug mode 0
03-16 01:51:14.043    1913-1928/com.example.dushani.emailsender W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-16 01:51:14.044    1913-1928/com.example.dushani.emailsender W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6e0df20, error=EGL_SUCCESS
03-16 01:51:47.305    1913-1928/com.example.dushani.emailsender W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-16 01:51:47.305    1913-1928/com.example.dushani.emailsender W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6e0df20, error=EGL_SUCCESS
03-16 01:52:30.073    1913-1925/com.example.dushani.emailsender I/art﹕ Background sticky concurrent mark sweep GC freed 1881(109KB) AllocSpace objects, 0(0B) LOS objects, 23% free, 723KB/948KB, paused 1.427ms total 111.164ms
我用这个方法,

Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    String possibleEmail = new String();
    mailArray = new String[]{getString(R.string.mail), possibleEmail};

    Pattern emailPattern = Patterns.EMAIL_ADDRESS;
    Account[] accounts = AccountManager.get(getBaseContext()).getAccounts();

    for (Account account : accounts) {
        if (emailPattern.matcher(account.name).matches()) {
            possibleEmail = account.name;
        }
    }

    if(sendToMeCheckBox.isChecked()){

        mailArray [1] = possibleEmail;
    }

    intent.putExtra(Intent.EXTRA_EMAIL, mailArray );
    intent.putExtra(Intent.EXTRA_SUBJECT, "Some random subject");
    intent.putExtra(Intent.EXTRA_TEXT, "Some random text");

    try {
        startActivity(Intent.createChooser(intent, "Send email..."));
    } catch (Exception e) {
        Toast.makeText(this, "There are no mail applications on the device!", Toast.LENGTH_LONG).show();
    }
}

在这里粘贴你的代码!这看起来像是一个OGL问题,不是电子邮件。你能告诉我什么是OGL问题吗?有没有办法解决这个问题。我正在使用android studio开发一个应用程序。第一个用户必须通过向其提供电子邮件和密码来注册应用程序。之后,该用户必须提供密码,并且该密码必须发送到其电子邮件帐户(发件人和收件人的电子邮件地址相同)。如果您有更好的方法,请与我们共享任何代码片段。此答案不解决有关
错误
JavaMail API
的问题。此外,问题建议不要使用
意图
。我怎么不使用意图呢。我在开始时创建对象,并在try块中的startActivity方法中使用它。选择器只是为应用程序提供了多个使用意图对象的选项。是的,我没有回答这些问题,这不是我的本意,我只是想展示一个例子,说明我是如何做到的,因为没有其他人回答。