Вопрос

onProviderDisabled is telling me the gps is disabled. I want to be able to get the lat and lon in the wifi gps mode as well as the full gps mode.

I am using this code to start up

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);


locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
        3000,   
        1, this);

It all works with the full GPS on but I need to be able to get the lat and lon in either mode.

Это было полезно?

Решение

You can request updates from more than one provider. Add the following line:

locationManager.requestLocationUpdates(LocationManager. NETWORK_PROVIDER, 3000, 1, this);

The same callback methods, i.e. onLocationChanged(), onProviderDisabled(), etc., will be used to pass the updates from both providers. If you need to know which provider is passing the update, you can use the Location.getProvider() method in onLocationChanged(), and the String provider parameter passed in the others.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top