title: Convert editText number input to percentage in real time not working in real device
body: <p>I'm trying to convert the input of an editText to percentage while the user input it, the following code is not working, on the real device. It does format correctly on emulator.</p>
  
  <pre><code>public class PercentTextWatcher implements TextWatcher {
  
  private final EditText percentage;
  private final Locale locale;
  
  
  public PercentTextWatcher(EditText percentage, Locale locale) {
      this.percentage = percentage;
      this.locale = locale;
  }
  
  @Override
  public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
  }
  
  @Override
  public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  }
  
  @Override
  public void afterTextChanged(Editable editable) {
      percentage.removeTextChangedListener(this);
      if (percentage == null) return;
      percentage.removeTextChangedListener(this);
  
      NumberFormat format = NumberFormat.getPercentInstance(locale);
      format.setMaximumFractionDigits(4);
      String percentNumber = format.format(convertToDouble(percentage.getText().toString())/1000);
  
      percentage.setText(percentNumber);
      percentage.setSelection(percentNumber.length()-1);
      percentage.addTextChangedListener(this);
  
  }
  
  private double convertToDouble(String value) {
      double convertedNumber = 0;
      NumberFormat nf = new DecimalFormat("##,##");
      try {
          convertedNumber = nf.parse(value).doubleValue();
      } catch (ParseException e) {
          e.printStackTrace();
      }
      return convertedNumber;
  }
  </code></pre>
  
  <p>The keyboard does not accept anymore input after the first char, and returns 0,001% for example. </p>