Code example for LocationManager: Getting continuous location updates

Methods: addTestProvidergetProviderremoveTestProviderrequestLocationUpdatessetTestProviderEnabledsetTestProviderLocationsetTestProviderStatus

0
	 */ 
	public static void publishMockLocation(double latitude, double longitude, Context context, ArrayList<CheckPoint> checkPoints,
			MapLocationListener locationListener)
	{ 
		LocationManager locationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
		if (locationManager.getProvider(PROVIDER_NAME) != null)
		{ 
			locationManager.removeTestProvider(PROVIDER_NAME);
		} 
		if (locationManager.getProvider(PROVIDER_NAME) == null)
		{ 
			locationManager.addTestProvider(PROVIDER_NAME, "requiresNetwork" == "", "requiresSatellite" == "", "requiresCell" == "",
					"hasMonetaryCost" == "", "supportsAltitude" == "", "supportsSpeed" == "", "supportsBearing" == "", 
					android.location.Criteria.POWER_LOW, android.location.Criteria.ACCURACY_FINE);
		} 
 
		Location newLocation = new Location(PROVIDER_NAME);
		newLocation.setLatitude(latitude);
		newLocation.setLongitude(longitude);
		newLocation.setTime(System.currentTimeMillis());
		newLocation.setAccuracy(25);
 
		locationManager.setTestProviderEnabled(PROVIDER_NAME, true);
		locationManager.setTestProviderStatus(PROVIDER_NAME, LocationProvider.AVAILABLE, null, System.currentTimeMillis());
		locationManager.requestLocationUpdates(PROVIDER_NAME, 0, 0, locationListener);
		locationManager.setTestProviderLocation(PROVIDER_NAME, newLocation);
	} 
 
	/** 
	 * Gets the last known location from the application you are testing. 
	 * @param context the context you are testing in