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