问题
How can i get current location using WiFi? In my project using gps I can get current location ... How can I use network service in android?
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener currentlocation = new CurrentLocation();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
currentlocation);
But I want current location WiFi? Can anyone help me for getting current location using WiFi?
回答1:
Try to use NETWORK_PROVIDER.
Please note, that you will have to amend your AndroidManifest.xml as well by adding:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
来源:https://stackoverflow.com/questions/10172136/get-current-location-using-wifi