LocationManager setTestProviderLocation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LocationManager setTestProviderLocation method.

This code example shows how to use the following methods:addTestProvider, setTestProviderEnabled, setTestProviderLocation, setTestProviderStatus, sleep
		double longitude = -88.22055;	
		Location fakeLocation = new Location(LocationManager.GPS_PROVIDER);		
		 
		try 
		{ 
			manager.addTestProvider(LocationManager.GPS_PROVIDER, true, true, true, true, true, true, true, 0, 5);
			manager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
			manager.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null,System.currentTimeMillis());
		} 
		catch (Exception ex) {}
		 
		fakeLocation.setLatitude(latitude);
		fakeLocation.setLongitude(longitude);
		manager.setTestProviderLocation(LocationManager.GPS_PROVIDER, fakeLocation);	
		((RouteMap)mActivity).setMapCenter((int)(latitude * 1E6), (int)(longitude * 1E6));
		 
		thisWait(2000); 
		 
		((RouteMap)mActivity).clickOnOverlay(); // springfield and gregory ne corner
		 

6
CodeRank
This code example shows how to use the following methods:addTestProvider, requestLocationUpdates, setTestProviderEnabled, setTestProviderLocation, setTestProviderStatus
    } 
 
	private void doIt () 
    { 
 
    	lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {       
    	            @Override 
    	            public void onStatusChanged(String provider, int status, Bundle extras) {}
    	            @Override 
    	            public void onProviderEnabled(String provider) {}
    	            @Override 
    	            public void onProviderDisabled(String provider) {}
    	            @Override 
    	            public void onLocationChanged(Location location) {}
    	}); 
    	             
    	/* Set a mock location for debugging purposes */ 
    	setMockLocation(15.387653, 73.872585, 500); 
    } 
     

6
CodeRank
This code example shows how to use the following methods:setTestProviderLocation
                } 
            } catch (Exception e) {
                //Method only available in Jelly Bean 
            } 
 
            locationManager.setTestProviderLocation(locationProvider, location);
    	} 
 
    	public void finish() { 
    		finish = true;
    	} 
    } 
 
    @Override 
    public String key() {
        return "set_gps_coordinates"; 
    } 
 
    private boolean doesDeviceProvideGPS() { 
    LocationManager locationManager = (LocationManager) InstrumentationBackend.solo.getCurrentActivity().getSystemService(Context.LOCATION_SERVICE);
6
CodeRank
This code example shows how to use the following methods:addTestProvider, getLastKnownLocation, setTestProviderEnabled, setTestProviderLocation
		      "mock locations"); 
		}			 
		 
		// Get the location manager 
		LocationManager locationManager = (LocationManager) this.getActivity().getSystemService(Service.LOCATION_SERVICE);
		locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, true, true, true, 0, 5);
		Location mockLocation = new Location(LocationManager.GPS_PROVIDER);
		mockLocation.setLatitude(10.0);
		mockLocation.setLongitude(100.0);
		mockLocation.setTime(System.currentTimeMillis());
		locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
	    locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, mockLocation);
		Location loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
		System.out.println(loc.getLatitude() + "   " + loc.getLongitude());
	    assertEquals(10.0, loc.getLatitude());
	    assertEquals(100.0, loc.getLongitude());
	} 
} 
6
CodeRank
This code example shows how to use the following methods:addTestProvider, removeTestProvider, setTestProviderEnabled, setTestProviderLocation
	{ 
		double lat = 46.9513449;
		double lng = 7.4384537;
		Activity currentActivity = solo.getCurrentActivity();
		LocationManager testLocMgr = (LocationManager) currentActivity.getSystemService(Context.LOCATION_SERVICE);
		testLocMgr.addTestProvider("TestProvider", false, false, false, false, false, false, false,
			Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
		testLocMgr.setTestProviderEnabled("TestProvider", true);
 
		// Set up test 
		Location location = new Location("TestProvider");
		location.setLatitude(lat);
		location.setLongitude(lng);
		testLocMgr.setTestProviderLocation("TestProvider", location);
 
		// Check if your listener reacted the right way 
		double currentLatitude = ((ch.eonum.HealthActivity) currentActivity).getLocation().getLatitude();
		double currentLongitude = ((ch.eonum.HealthActivity) currentActivity).getLocation().getLongitude();
 
		assertEquals(lat, currentLatitude);

6
CodeRank
This code example shows how to use the following methods:addTestProvider, getLastKnownLocation, requestLocationUpdates, setTestProviderEnabled, setTestProviderLocation
	public void testPreconditions() { 
		assertNotNull(getActivity());
	} 
 
	public void testAddingLocationToATask() { 
		manager.addTestProvider(MOCK_GPS_PROVIDER, false, false, false, false,
				true, true, true, 0, 5); 
 
		// Setting a fake location to the mock provider 
		Location location = new Location(MOCK_GPS_PROVIDER);
		location.setLatitude(42.0);
		location.setLongitude(1337.0);
		location.setTime(System.currentTimeMillis()); // necessary to wake up
														// LocationListener 
		manager.setTestProviderLocation(MOCK_GPS_PROVIDER, location);
 
		// Enable mock provider 
		manager.setTestProviderEnabled(MOCK_GPS_PROVIDER, true);
 
		// Getting location updates 

7
CodeRank
This code example shows how to use the following methods:addTestProvider, getProvider, removeTestProvider, requestLocationUpdates, setTestProviderEnabled
	 */ 
	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());

6
CodeRank
This code example shows how to use the following methods:addTestProvider, removeTestProvider, setTestProviderEnabled, setTestProviderLocation
	public void testLocationService() 
	{ 
		double lat = 46.9513449;
		double lng = 7.4384537;
		LocationManager testLocMgr = (LocationManager) this.mActivity.getSystemService(Context.LOCATION_SERVICE);
		testLocMgr.addTestProvider("TestProvider", false, false, false, false, false, false, false,
			Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
		testLocMgr.setTestProviderEnabled("TestProvider", true);
 
		// Set up test 
 
		Location location = new Location("TestProvider");
		location.setLatitude(lat);
		location.setLongitude(lng);
		testLocMgr.setTestProviderLocation("TestProvider", location);
 
		// Check if your listener reacted the right way 
		double currentLatitude = mActivity.getLocation().getLatitude();
		double currentLongitude = mActivity.getLocation().getLongitude();
 

6
CodeRank
This code example shows how to use the following methods:addTestProvider, getLastKnownLocation, requestLocationUpdates, setTestProviderEnabled, setTestProviderLocation
 
	public TaskManagerLocationManager(Context context) {
		locationManager = (LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE);
 
		locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
				LOCATION_UPDATE_TIME, LOCATION_UPDATE_DISTANCE, this);
 
		setLatestLocation(locationManager
				.getLastKnownLocation(LocationManager.NETWORK_PROVIDER));
 
		setMockLocation(); 
	} 
 
	public void onLocationChanged(Location location) {
		setLatestLocation(location);
	} 
 
	public void onProviderDisabled(String provider) {
 

5
CodeRank
This code example shows how to use the following methods:getLastKnownLocation, requestLocationUpdates, setTestProviderLocation

Related LocationManager setTestProviderLocation Questions & Answers:

setTestProviderLocation Method Overview
Sets a mock location for the given provider.
See Code Examples for other Android LocationManager Methods: