0

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

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 :

Skipped 222 frames! The application may be doing too much work on its main thread.

Can anyone tell me what is the exact problem ?

slavoo
  • 5,798
  • 64
  • 37
  • 39
user3688536
  • 31
  • 1
  • 1
  • 7

1 Answers1

7

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();
ssi-anik
  • 2,998
  • 3
  • 23
  • 52
odiiil
  • 276
  • 1
  • 2
  • 9