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

This code example shows how to use the following methods:getProviders, requestLocationUpdates
		if (!started && hasSignificantlyOlderLocation()) {
			 
			started = true;
			 
			// get all enabled providers 
			List<String> enabledProviders = locationManager.getProviders(true);
			 
			boolean gpsProviderEnabled = enabledProviders.contains(LocationManager.GPS_PROVIDER);
			boolean networkProviderEnabled = enabledProviders.contains(LocationManager.NETWORK_PROVIDER);
			 
			if (gpsProviderEnabled || networkProviderEnabled) {
				if (gpsProviderEnabled) {
					locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_MIN_TIME, 0, this);
				} 
				if (networkProviderEnabled) {
					locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_MIN_TIME, 0, this);
				} 
				 
				Intent gpsIntent = new Intent(GPS_TIMEOUT_ACTION);
				PendingIntent pendingIntent = PendingIntent.getBroadcast(AbstractApplication.get(), 0, gpsIntent,
					PendingIntent.FLAG_CANCEL_CURRENT);
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:getProviders
    final LastLocationFinder lastLocationFinder = new LastLocationFinder(locationManager);
 
 
    @Before 
    public void setUp() throws Exception { 
        when(locationManager.getProviders(true)).thenReturn(providers);
    } 
 
    private Location getLastBestLocation() {
        return lastLocationFinder.getLastBestLocation(MIN_TIME);
    } 
 
    private Location addLocationToManager(long timestamp, float accuracy, String provider) {
        Location location = new Location(provider);
        location.setTime(timestamp);
        location.setAccuracy(accuracy);
        providers.add(provider);
        when(locationManager.getLastKnownLocation(provider)).thenReturn(location);
        return location;
    } 
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:setAltitudeRequired, setBearingRequired, setSpeedRequired, getProviders
	/** 
	 * @param activity the activity 
	 * @return the providers matching the application requirement 
	 */ 
	private static List<String> getProviders(Activity activity) {
		Criteria criteria = new Criteria();
		// criteria.setAccuracy(Criteria.ACCURACY_FINE); any accuracy 
		criteria.setAltitudeRequired(false); // no altitude
		criteria.setBearingRequired(false); // no compass... for now ;)
		criteria.setSpeedRequired(false); // no speed required
		boolean enabledOnly = true; // only enabled location providers
		List<String> providers = getLocationManager(activity).getProviders(criteria, enabledOnly);
		// MyLog.d(TAG, "nb location providers: %s", providers.size()); 
		return providers;
	} 
 
	/** 
	 * @param activity the activity 
	 * @return the location manager service 
	 */ 
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:getProviders, isProviderEnabled, requestLocationUpdates
        super.onStart(intent, startId);    //To change body of overridden methods use File | Settings | File Templates.
        if (mLocationManager == null)
            mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria = new Criteria();
        criteria.setAccuracy(200);
        mLocationManager.getProviders(criteria, true);
 
        if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
            Log.v("GPSStatus", "GPS disabled");
        else 
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 35, this);
    } 
 
    @Override 
    public void onDestroy() { 
        super.onDestroy();    //To change body of overridden methods use File | Settings | File Templates. 
        if (mLocationManager != null && mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            mLocationManager.removeUpdates(this);
            mLocationManager = null;
        } 
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:getBestProvider, getProviders, requestLocationUpdates
		                Bundle extras) {
		    // TODO Auto-generated method stub 
			 
		   }         
		}; 
		locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), 2000, 4, locationListener);
		Toast.makeText(getApplicationContext(), "Location Tracked Using: " + locationManager.getProviders(true) , Toast.LENGTH_SHORT).show();
		 
		// now remove updating of co-ordinates  
		 
		 
		 
	} 
} 
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:getProviders, removeUpdates, requestLocationUpdates
		tearDownForGPSAutoRefreshing(); 
		super.onDestroy(); 
	} 
 
	private void setupForGPSAutoRefreshing() { 
		List<String> providers = this.locationManager.getProviders(true);
		String provider = providers.get(0);
 
		long minTimeBetweenUp = (Integer) Session
				.get("position.notification.rate") * 1000; 
 
		locationManager.requestLocationUpdates(provider, minTimeBetweenUp,
				MIN_DISTANCE, listener);
	} 
 
	private void tearDownForGPSAutoRefreshing() { 
		locationManager.removeUpdates(listener);
	} 
 
	@Override 

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:getProviders, isProviderEnabled
		} 
	} 
 
	public boolean checkLocationService(LocationManager locationManager) {
		Util.location("checkLocationService "); 
		List<String> providers = locationManager.getProviders(true);
		if (providers.size() == 0) {
			Util.location("No location Providers can use!!!!!bad bad bad!"); 
			return false; 
		} 
		if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || !locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
			Util.location("gps location provider is not enabled!!!bad bad bad"); 
			return false; 
		} 
		return true; 
	} 
 
	public void unregister(LocationManager locationManager) {
		locationManager.removeUpdates(this);
	} 
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:getProviders, requestLocationUpdates
		return singleton;
	} 
	 
	private GeoLocationManager (Context context) throws NoLocationProviderException { 
		lManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
		lManager.requestLocationUpdates(this.getBestLocationProvider(), MIN_TIME_MS, MIN_DIST_METER, this);
	} 
	 
	/** 
	 * Best active location provider 
	 */ 
	private String getBestLocationProvider() throws NoLocationProviderException {
		java.util.List<String> providers = lManager.getProviders(true);
		 
		if (providers != null && providers.size() > 0 && providers.contains(LocationManager.GPS_PROVIDER)) {
		    return LocationManager.GPS_PROVIDER;
		} else if (providers != null && providers.size() > 0 && providers.contains(LocationManager.NETWORK_PROVIDER)) {
		    return LocationManager.NETWORK_PROVIDER;
		} else { 
			throw new NoLocationProviderException(); 
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:getProviders, requestLocationUpdates
  
		//TODO 
	} 
	 
	private void getPosition() { 
		lManager.requestLocationUpdates(lManager.getProviders(true).get(0), 60000, 0, this);
	} 
	 
	public void onLocationChanged(Location location) {
		this.location = location;
		updateLocationDisplay(); 
	} 
 
	private void updateLocationDisplay() { 
		((TextView)findViewById(R.id.latitude_data)).setText(String.valueOf(location.getLatitude()));
		((TextView)findViewById(R.id.longitude_data)).setText(String.valueOf(location.getLongitude()));
	} 
 
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub	 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getProviders, removeTestProvider
 
	@Override 
	public void onDestroy() 
	{ 
		super.onPause(); 
		if (locationManager.getProviders(true).contains(TEST_PROVIDER)) {
			locationManager.removeTestProvider(TEST_PROVIDER);
		} 
	} 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related LocationManager getProviders Questions & Answers:

getProviders Method Overview
Returns a list of the names of location providers.
See Code Examples for other Android LocationManager Methods: