문제

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