gpt4 book ai didi

android - 在 Android 中发送电子邮件

转载 作者:太空狗 更新时间:2023-10-29 13:20:58 26 4
gpt4 key购买 nike

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

我根据这个创建了我的应用程序:-

Sending Email in Android using JavaMail API without using the default/built-in app

这是我收到的 logcat 消息。

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();
}
}

关于android - 在 Android 中发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29066205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com