Skip to content Skip to sidebar Skip to footer

Android Location Manager Issue

From the following code, I get the current location. Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria

Solution 1:

This has been answered before. You need to add two different location listeners. One for the GPS and one using the network position. Cellular network based location listener.

GPS will work only outdoors but the cellular network would work anywhere there are signals however it isn't as accurate as the GPS is.

locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
            locationListener = newMyLocationListener();
            locationListener2 = newMyLocationListener();               
            locationManager.requestLocationUpdates(locationManager.GPS_PROVIDER, 0, 0, locationListener);
            locationManager.requestLocationUpdates(locationManager.NETWORK_PROVIDER, 0, 0, locationListener2);

Solution 2:

When you get a fix, use the Location.getProvider() to know which provider was used.

Use this elaborate article to decide which LocationProvider is the best.

Post a Comment for "Android Location Manager Issue"