该应用程序可能在其主线程上做了太多工作 - Android [英] The application may be doing too much work on its main thread - Android
问题描述
您好,我正在开发一个 Android 应用程序,当我尝试从我的应用程序发送电子邮件时遇到此错误.我在后台发送邮件而不使用基于 this链接
Hi I am developing an android application where I face this error when I try to send Email from my app. I am sending mail at the background without using intent based on this link
我的程序:
String em[] = {gete(u, e)};
MailSender sender = new GMailSender(
"email id",
"password");
sender.sendMail("Sub", "Body", "from address",""+em[0]);
move();
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
}
}).start();
}
});
当我直接指定收件人的电子邮件地址时,应用程序工作正常.当我将其指定为存储收件人电子邮件地址的字符串数组时,问题就来了.
Application works fine when I specify the recipient's email address directly. Problem comes when I specify it as string array where I stored recipients email addresses.
Logcat 显示:
跳过了 222 帧!应用程序可能在其主线程上做了太多工作.
Skipped 222 frames! The application may be doing too much work on its main thread.
谁能告诉我具体的问题是什么?
Can anyone tell me what is the exact problem ?
推荐答案
就像对你说的那样,你做的事情太多了.所以使用一个线程来执行你的发送操作:
As it is said to you, you're doing too much things. So use a thread to execute your send action:
new Thread(new Runnable() {
public void run() {
try {
sender.sendMail("Sub", "Body", "from address",""+em[0]);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
}).start();
这篇关于该应用程序可能在其主线程上做了太多工作 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!