Why is my AsyncTask freeza?

0

At the moment I instantiate an object EmailTask the app hangs = (

public void send(View view){
       EditText text = (EditText) findViewById(R.id.editText);
        Switch iluminacao = (Switch) findViewById(R.id.switch1);
        Switch wifi = (Switch) findViewById(R.id.switch2);
        RatingBar mBar = (RatingBar) findViewById(R.id.ratingBar);
        try {
            EmailTask asyncTask = new EmailTask(text.getText().toString(), iluminacao.isChecked(), wifi.isChecked(), mBar.getNumStars());

            asyncTask.execute();
        }catch(Exception e){
            e.printStackTrace();
        }          
    }

My AsyncTask

package com.morais.daniela.conectasp;

import android.os.AsyncTask;
import android.os.Build;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

/**
 * Created by daniela.morais on 24/03/15.
 */
public class EmailTask extends AsyncTask<Void, Void, Void> {
    private String comments;
    private boolean getIluminacao;
    private boolean getWifi;
    private float getStars;
    private SimpleEmail email = new SimpleEmail();

    /**
     * Recebe feedbacks enviados pelo usuario e inicializa configuracoes do email
     * @param comments
     * @param getIluminacao
     * @param getWifi
     * @param getStars
     */
    public EmailTask(String comments, boolean getIluminacao, boolean getWifi, float getStars) {
        this.comments = comments;
        this.getIluminacao = getIluminacao;
        this.getWifi = getWifi;
        this.getStars = getStars;
        email.setSSLOnConnect(true);
        email.setHostName("smtp.gmail.com");
        email.setSslSmtpPort("465");
        email.setAuthenticator(new DefaultAuthenticator("[email protected]","senha"));
    }

    /**
     * Encaminhar email
     * @param params
     * @return
     */
    @Override
    protected Void doInBackground(Void... params) {
        String iluminacao = "Não.";
        String wifi = "Não.";
        if(getIluminacao==true){
            iluminacao = "Sim.";
        }
        if(getWifi==true){
            wifi = "Sim.";
        }

        try {
            email.setFrom("[email protected]");
            email.setDebug(true);
            email.setSubject("Feedback - ConectaSP");
            email.setMsg("Houve problemas com a iluminação? " + iluminacao + "\n\n"
                    + "Houve problemas com o wifi? " + wifi + "\n\n"
                    + "Avaliação geral " + getStars + "\n\n"
                    + "Comentários:\n" + comments + "\n\n"
                    + "Informações gerais do aparelho\n" + Build.DEVICE + "\t" + Build.HARDWARE + "\t" + Build.MODEL);
            email.addTo("[email protected]");
            email.send();
        } catch (EmailException e) {
            System.err.println("Erro ao enviar email.");
        }
        return null;
    }
}

Error

03-24 16:10:13.790    7215-7215/com.morais.daniela.conectasp E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.IllegalStateException: Could not execute method of the activity
            at android.view.View$1.onClick(View.java:3103)
            at android.view.View.performClick(View.java:3574)
            at android.view.View$PerformClick.run(View.java:14293)
            at android.os.Handler.handleCallback(Handler.java:605)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4448)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at android.view.View$1.onClick(View.java:3098)
            at android.view.View.performClick(View.java:3574)
            at android.view.View$PerformClick.run(View.java:14293)
            at android.os.Handler.handleCallback(Handler.java:605)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4448)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.VerifyError: com/morais/daniela/conectasp/EmailTask
            at com.morais.daniela.conectasp.FeedbackActivity.send(FeedbackActivity.java:50)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at android.view.View$1.onClick(View.java:3098)
            at android.view.View.performClick(View.java:3574)
            at android.view.View$PerformClick.run(View.java:14293)
            at android.os.Handler.handleCallback(Handler.java:605)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4448)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
            at dalvik.system.NativeStart.main(Native Method)
    
asked by anonymous 24.03.2015 / 20:16

0 answers