So I have a Start Button 1 where when it's clicked, it grabs the text from EditText1 and then calls CountDownTimer to call a method that passes the text from EditText1 through its parameters and display something in TextView1 every 10 seconds. However, if you decide to type something else in EditText1 and click the start button 1 again, it will call the CountDownTimer again.
In this case, there will be 2 "doThis" CountDownTimer variables, and doing doThis.cancel() will only cancel the second "doThis" CountDownTimer variable. I'm wondering how to fix this.
[EditText1]
[Start Button 1] [TextView1] [End Button 1]
[Start Button 2] [TextView2] [End Button 2]
CountDownTimer doThis;
doThis = new CountDownTimer(10000,10000)
{
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
start();
TextView text = (TextView)findViewById(R.id.text);
try {
Date date = new Date(System.currentTimeMillis());
text.setText(myMethod(variableFromEditText1));
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();