Get current location using wifi?

2019-09-21 11:49发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-09-21 12:34

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" />
查看更多
登录 后发表回答