I use if(pause == null)
to do something when pause
is null
. But I get the error
the operator == is undefined for the argument type(s) long,null
Here is the code,
public class Timer extends CountDownTimer {
long pause = (Long) null;
public Timer(long startTime, long interval) {
super(startTime, interval);
}
@Override
public void onTick(long millisUntilFinished) {
content.setText("Tijd over: " + millisUntilFinished / 100);
}
public void onPause(long millisUntilFinished) {
if(pause == null) {
pause = millisUntilFinished;
content.setText("Tijd over: " + millisUntilFinished / 100);
this.cancel();
}
else {
this.start();
}
}
@Override
public void onFinish() {
content.setText("Tijd is op!");
}
}
This class isn't finished, so ignore the rest of the code.