LocationManager getProvider - 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 getProvider method.

This code example shows how to use the following methods:addTestProvider, getProvider, setTestProviderEnabled
        } 
    } 
 
    private void setupMockLocations() { 
        try { 
            if(mLocationManager.getProvider(
                        VEHICLE_LOCATION_PROVIDER) == null) {
                mLocationManager.addTestProvider(VEHICLE_LOCATION_PROVIDER,
                        false, false, false, false, false, true, false, 0, 5); 
            } 
            mLocationManager.setTestProviderEnabled(
                    VEHICLE_LOCATION_PROVIDER, true);
        } catch(SecurityException e) {
            Log.w(TAG, "Unable to use mocked locations, " +
                    "insufficient privileges", e);
            mLocationManager = null;
        } 
    } 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTestProvider, getAllProviders, getProvider, removeTestProvider, setTestProviderEnabled
 
	    Log.w(TAG, "LastKnownLocation of "+provider+" is: "+manager.getLastKnownLocation(provider));
	} 
 
	public static void createMockLocationProvider(LocationManager manager, String provider) {
		Log.w(TAG, "Providers: " + manager.getAllProviders().toString());
	    if(manager.getProvider(provider) != null) {
	      Log.w(TAG, "Removing provider " + provider);
	      manager.removeTestProvider(provider);
	    } 
	    Log.w(TAG, "Providers: " + manager.getAllProviders().toString());
 
	    if(manager.getProvider(provider) == null) {
	      Log.w(TAG, "Adding provider " + provider + " again");
	      manager.addTestProvider(provider, "requiresNetwork" == "", "requiresSatellite" == "",
	          "requiresCell" == "", "hasMonetaryCost" == "", "supportsAltitude" == "", "supportsSpeed" == "", 
	          "supportsBearing" == "", android.location.Criteria.POWER_LOW, android.location.Criteria.ACCURACY_FINE);
	    } 
	    Log.w(TAG, "Providers: " + manager.getAllProviders().toString());
 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getProvider, isProviderEnabled, requestLocationUpdates
		point.set(x / 2, y / 2);
	} 
 
	protected void setUpGPS(){	 
		locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
	    final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
	    if (!gpsEnabled) {
	    	enableLocationSettings();// 
	    } 
		LocationProvider provider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
		ggcLocactionListener = new GGCLocationListener();
		locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,10000,10, ggcLocactionListener);	
	} 
	 
	private void enableLocationSettings() { 
	    Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
	    startActivity(settingsIntent);
	} 
	 
	protected void onStop() { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getProvider, isProviderEnabled
		} 
	} 
 
	/** Write information from a single location provider */ 
	private void dumpProvider(String provider) {
		LocationProvider info = mgr.getProvider(provider);
		StringBuilder builder = new StringBuilder();
		builder.append("LocationProvider[").append("name=")
				.append(info.getName()).append(",enabled=")
				.append(mgr.isProviderEnabled(provider))
				.append(",getAccuracy=").append(A[info.getAccuracy() + 1])
				.append(",getPowerRequirement=")
				.append(P[info.getPowerRequirement() + 1])
				.append(",hasMonetaryCost=").append(info.hasMonetaryCost())
				.append(",requiresCell=").append(info.requiresCell())
				.append(",requiresNetwork=").append(info.requiresNetwork())
				.append(",requiresSatellite=").append(info.requiresSatellite())
				.append(",supportsAltitude=").append(info.supportsAltitude())
				.append(",supportsBearing=").append(info.supportsBearing())
				.append(",supportsSpeed=").append(info.supportsSpeed())
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTestProvider, getProvider, requestLocationUpdates, setTestProviderEnabled
 
		locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
 
		if (mockStatus) {
 
			if (locationManager.getProvider("testProvider") == null) {
				locationManager.addTestProvider("testProvider", false, true, false, false, true, true, false, 0, 5);
			} 
			locationManager.setTestProviderEnabled("testProvider", true);
 
			locationManager.requestLocationUpdates("testProvider", 1000, 0, location);
 
			// locationManager.setTestProviderStatus("testProvider", 
			// LocationProvider.AVAILABLE, null, System.currentTimeMillis()); 
 
		} else { 
 
			locationManager.requestLocationUpdates(locationManager.GPS_PROVIDER, 1000, 0, location);
 
		} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getProvider, isProviderEnabled
  InternalGPS(Context context, int _index) {
    index = _index;
 
    locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
    if (locationManager == null ||
        locationManager.getProvider(locationProvider) == null) {
      /* on the Nook Simple Touch, LocationManager.isProviderEnabled() 
         can crash, but LocationManager.getProvider() appears to be 
         safe, therefore we're first checking the latter; if the 
         device does have a GPS, it returns non-null even when the 
         user has disabled GPS */ 
      locationProvider = null;
    } else if (!locationManager.isProviderEnabled(locationProvider) &&
        !queriedLocationSettings) {
      // Let user turn on GPS, XCSoar is not allowed to. 
      Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
      context.startActivity(myIntent);
      queriedLocationSettings = true;
    } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTestProvider, getProvider, removeTestProvider, setTestProviderEnabled
		logger.d("Registering provider: "+name);
		this.manager = manager;
		// Horrible Workaround: When shutting app from application manager (long press home+swipe) TestBaseActivity.onDestroy and,  
		// consequently, doUnbindService get called, but LocationService.onDestroy doesn't for some reason, leaving  
		// mockup-provider registered within the system and causing crash on next startup (Runtime Exception). 
		if(manager.getProvider(name)!=null) {
			manager.removeTestProvider(name);
		} 
		manager.addTestProvider(name, requiresNetwork, requiresSatellite, requiresCell, hasMonetaryCost, 
				supportsAltitude, supportsSpeed, supportsBearing, powerRequirement, accuracy);
		manager.setTestProviderEnabled(name, true);
		this.context = context;
	} 
	 
	private void firstRead(){ 
		try { 
			file = new BufferedReader(new InputStreamReader(context.getAssets().open("mock_positions.txt")));
			lines = new ArrayList<String>();
			String strLine;
			//Read File Line By Line 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getProvider, isProviderEnabled, requestLocationUpdates
   *  
   * @param listener the listener 
   */ 
  public void registerLocationListener(LocationListener listener) {
    // Check if the GPS provider exists 
    if (locationManager.getProvider(LocationManager.GPS_PROVIDER) == null) {
      listener.onProviderDisabled(LocationManager.GPS_PROVIDER);
      unregisterLocationListener(listener);
      return; 
    } 
 
    // Listen for GPS location 
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
 
    // Update the listener with the current provider state 
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      listener.onProviderEnabled(LocationManager.GPS_PROVIDER);
    } else { 
      listener.onProviderDisabled(LocationManager.GPS_PROVIDER);
    } 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addTestProvider, getProvider, removeTestProvider, setTestProviderEnabled
		super.setUp(); 
		activity = getActivity();
 
		locationManager = (LocationManager) activity
				.getSystemService(Context.LOCATION_SERVICE);
		if (locationManager.getProvider(provider) != null) {
			locationManager.removeTestProvider(provider);
		} 
		locationManager.addTestProvider(provider, false, false, false, false,
				false, false, false, Criteria.POWER_MEDIUM,
				Criteria.ACCURACY_MEDIUM);
		locationManager.setTestProviderEnabled(provider, true);
	} 
 
	@Override 
	protected void tearDown() throws Exception { 
 
		locationManager.removeTestProvider(provider);
		super.tearDown(); 
	} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related LocationManager getProvider Questions & Answers:

getProvider Method Overview
Returns the information associated with the location provider of the given name, or null if no provider exists by that name.
See Code Examples for other Android LocationManager Methods: