title: Android - EditText deleted when i use the method setSelection inside the method onTextChanged
body: <p>I'm trying put a mask of phone by the method onTextChanged, the text in this method is coming unlike, and when try use the method setSelection for position the cursor on final, the text of editText is deleted, this is happening on the Galaxy Tab 10, someone has an idea and how to solve it??</p>
  
  <pre><code>private TextWatcher filterTextWatcherTelefone = new TextWatcher() {
          public void afterTextChanged(Editable s) {
  
  
          }
  
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
          }
  
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              try {
                  if (atualizando) {
                      atualizando = false;
                      return;
                  }
  
  
                  String resultado = limparFormatacaoNumero(s.toString()); // CLEAR FORMATING
  
                  if (isNumero(resultado)) {// IS IT NUMBER?
  
                      if (resultado.length() &lt;= 14) {
                          resultado = adicionarFormatacaoTelefone(resultado);//FORMAT AS PHONE NUMBER
  
                      } else {
                          resultado = resultado.substring(0, 14);
                          resultado = adicionarFormatacaoTelefone(resultado); //FORMAT AS PHONE NUMBER
                      }
                      atualizando = true; //UPDATING = true
  
                      // THE TWO LINES BELOW GENERATES THE PROBLEM. WHEN COMMMENTED, THE                            
                      // ERASE ERROR DOESN'T APPEAR. OTHERWISE, IT REVERSES THE STRING
                      textoDiscagem.setText(resultado);
                      textoDiscagem.setSelection(textoDiscagem.getText().length());
  
                  }
              } catch (Exception e) {
              }
          }
      };
  </code></pre>