Button does not call the web service method

3

I'm having difficulty calling a method from my webservice, this method I send the e-ticket to the user for some reason is not working. I have a listview with all the tickets and the user selects which of them he wants to see the details and in this activity of details I have 3 functions that is to send the ticket by email, send a digible line of the ticket by sms or just to show the line.

This is the onClick method I have in detail activity. something's missing? because neither 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;
    
asked by anonymous 06.12.2016 / 12:28

1 answer

0

I was able to solve the problem by researching more about what could be causing my problem, I found 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();
            }

        }
    };

in the onCreate method:

enviaBoletoEmail = (Button) findViewById(R.id.enviaBoletoEmail);
enviaBoletoEmail.setOnClickListener(btnEnviaBoletoPDF);
    
06.12.2016 / 16:46