android – Button does not call web service method

Question:

I'm having difficulty calling a method of my webservice, this method I send the slip by email to the user, for some reason it's not working. I have a listview with all the slips and the user selects which one he wants to see the details and in this detail activity I have 3 functions which is to send the slip by email, send the slip typed line by sms or just show the line.

This is the onClick method I have on the detail activity. something's missing? because not even the logs they show me.

 @Override
    public void onClick(View v) {
       switch (v.getId()){

           case R.id.enviaBoletoEmail:
               Log.d("","ENVIANDO BOLETO test 1");

               new Thread(new Runnable() {
                      @Override
                      public void run() {
                          WebService ws = new WebService();
                          Log.d("","ENVIANDO BOLETO teste 2");
                          try {
                              pessoaDao = new PessoaDao(databaseHelper.getConnectionSource());
                              Pessoa pessoa=new Pessoa();
                              pessoa= pessoaDao.queryForId(1);

                              try {
                                  ws.enviarBoletoPDF(sequencia, pessoa.getEmail());

                                  Log.d("","ENVIANDO BOLETO test 3");

                              } catch (IOException e) {
                                  e.printStackTrace();
                              } catch (XmlPullParserException e) {
                                  e.printStackTrace();
                              }


                          } catch (SQLException e) {
                              e.printStackTrace();
                          }




                      }
                  }).start();

            break;

Answer:

I managed to resolve the issue, researching further what could be causing my problem, I found about good practices on how to use click events.

It was as follows:

public View.OnClickListener btnEnviaBoletoPDF = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
             WebService ws = new WebService();

            try {

                pessoaDao = new PessoaDao(databaseHelper.getConnectionSource());
                Pessoa pessoa = new Pessoa();
                pessoa = pessoaDao.queryForId(1);
                Log.d("Sequencia", sequencia);
                ws.enviarBoletoPDF(sequencia,pessoa.getEmail());

            } catch (IOException e) {
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }
    };

no onCreate method:

enviaBoletoEmail = (Button) findViewById(R.id.enviaBoletoEmail);
enviaBoletoEmail.setOnClickListener(btnEnviaBoletoPDF);
Scroll to Top