I need to return the value from my countdowntimer so I can update a textView. I'm not sure how I can do this, I've added a comment where I've tried adding a return but no luck.
public class BrewTimer extends Activity{
public String secsRemain = "not set";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("Timer Created, we're in the onCreate Method.");
}
public void startBrewTimer(long remaningMillis) {
// Start the Brew Timer
System.out.println("Timer object fired!");
new CountDownTimer(remaningMillis, 1000) {
public void onTick(long millisUntilFinished) {
secsRemain = "seconds remaining: " + millisUntilFinished / 1000;
System.out.println(secsRemain);
return secsRemain; // <-- This is what I want to do
}
public void onFinish() {
System.out.println("Timer Finished!!!");
}
}.start();
}
public void stopBrewTimer() {
//Stop the Brew Timer
}
}
void
,public void onTick(long millisUntilFinished) {
you can'treturn
anything. But see Raghunandan's answer. – Myrmecophagous