Timer did not start counting

78 views Asked by At

I have timer that running if i had out of radius of some specific Latitude and longitude. When i tried to put this code in onCreate() method, its run properly. But when i tried to put this code in onServiceUpdate method , it is not start counting. This method is similiar lika onLocationChanged() in googleMaps API.

Here is the code :

public void onServiceUpdate(ServiceState state) {
final float[] distance = new float[2];
    Location.distanceBetween(state.getGeoPoint().getLatitude(), state.getGeoPoint().getLongitude(), -6.182215, 106.785118, distance);
    if (distance[0] > 100.0) {
        countDownTimer = new CountDownTimer(5000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                txtCount.setText("Second : " + millisUntilFinished /1000);
            }

            @Override
            public void onFinish() {
                txtCount.setText("Finish !");
            }
        }.start();
        countDownTimer.start();
    }
}

Any idea ?

0

There are 0 answers