该应用程序可能会做太多的工作在其主线程 - Android电子 [英] The application may be doing too much work on its main thread - Android

查看:1041
本文介绍了该应用程序可能会做太多的工作在其主线程 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在开发的地方,当我试图从我的应用程序发送电子邮件我面对这个错误的Andr​​oid应用。我在后台发送邮件,而无需使用基于这个意图链接

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中所示:

Logcat shows :

跳过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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆