Code example for Timer

Methods: schedule

0
			lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
					locationListenerGps);
		if (network_enabled)
			lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
					locationListenerNetwork);
		timer1 = new Timer();
		timer1.schedule(new GetLastLocation(), 20000);
		return true; 
	} 
 
	LocationListener locationListenerGps = new LocationListener() {
		public void onLocationChanged(Location location) { 
			timer1.cancel(); 
			locationResult.gotLocation(location); 
			lm.removeUpdates(this); 
			lm.removeUpdates(locationListenerNetwork); 
		} 
 
		public void onProviderDisabled(String provider) { 
		} 
Contextual code suggestions in your IDE  Get Codota for Java