简体   繁体   English

该应用程序可能在其主线程上做太多工作-Android

[英]The application may be doing too much work on its main thread - Android

Hi I am developing an android application where I face this error when I try to send Email from my app. 嗨,我正在开发一个android应用程序,当我尝试从我的应用程序发送电子邮件时遇到此错误。 I am sending mail at the background without using intent based on this link 我在后台发送邮件,而没有使用基于此链接的意图

My program: 我的程序:

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 shows : Logcat显示:

Skipped 222 frames! 跳过222帧! 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: 因此,使用线程执行您的send操作:

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

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

相关问题 该应用程序可能在其主线程上做了大量工作(Android) - The application may be doing too much work on its main thread, (Android) Android-该应用程序可能在其主线程上做了大量工作 - Android - The application may be doing too much work on its main thread Android:该应用程序可能在其主线程上做了大量工作 - Android : The application may be doing too much work on its main thread 在主线程中使用转换 animation 是应用程序可能在 android 的主线程上做太多工作的原因 - using transitions animation in main thread is the reason for The application may be doing too much work on its main thread in android 我的应用程序可能在其主线程上做过多的工作 - My application may be doing too much work on its main thread 该应用程序可能在其主线程上做过多的工作 - The application may be doing too much work on its main thread 应用程序可能在其主线程上做太多工作 - Application may be doing too much work on its main thread 应用程序可能在其主线程消息上做过多的工作 - the application may be doing too much work on its main thread message 片段:应用程序可能在其主线程上做太多工作 - Fragment: The application may be doing too much work on its main thread MapFragment-应用程序可能在其主线程上做过多的工作 - MapFragment - The application may be doing too much work on its main thread
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM