質問

I'm working on an application which uses location.

My problem:
When I'm looking for the best provider, I only get the "network".
I know why but I don't know how to improve this.
In the locations settings, when I check "parameter -> location" and "security settings -> Use wireless network", the LocationManager.getBestProvider() returns only network. When it is not checked, and the GPS is active, getBestProvider returns the GPS.

What I want to do is:
When both options are checked, how to use / detect the GPS, instead of the network, as the location provider.

役に立ちましたか?

解決

You have to first check whether GPS is on or not. If it is on then get the location from GPS, if not get the location from network.
To check the gps status use :

manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE );
boolean statusOfGPS = manager.isProviderEnabled(LocationManager.GPS_PROVIDER);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top