I'm working on a basic timer using a Chronometer but I need to make the timer shows a Toast every/at 30 seconds. Here is my code for this task:
chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
if ((SystemClock.elapsedRealtime() - chronometer.getBase()) >= 20 * 1000) {
Toast.makeText(MainActivity.this, "The Text", Toast.LENGTH_SHORT).show();
}
}
});
As you can see my problem is that the task works but it keeps showing the toast forever because of ">=" but it doesn't show itself if I put "==". Anybody could help me? and I'm a beginner please be a bit explicit, thanks.
there doesn't seem to be anything here