Code example for Timer

Methods: schedule

0
        } 
        if (networkEnabled) {
            lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);
        } 
         
        timer1 = new Timer();
        timer1.schedule(new GetLastLocation(), TIMEOUT);
        return true; 
    } 
 
    LocationListener locationListenerGps = new LocationListener() {
        public void onLocationChanged(Location location) { 
            timer1.cancel(); 
            lm.removeUpdates(this); 
            lm.removeUpdates(locationListenerNetwork); 
            locationResult.gotLocation(location); 
        } 
        public void onProviderDisabled(String provider) {} 
        public void onProviderEnabled(String provider) {} 
        public void onStatusChanged(String provider, int status, Bundle extras) {} 
    };