How to get Location with Wifi in Android?

前端 未结 2 650
广开言路
广开言路 2021-01-05 13:55

I Want get location with Wifi and work in Google map, and it\'s not work for me but Gps is okay and not problem.

my code:

locationManager = (Location         


        
相关标签:
2条回答
  • 2021-01-05 14:27

    If you are connected to WIFI then simply use NETWORK PROVIDER for your location updates. they will be fast and enough accurate too.

    generally if location updates are not required so frequently then location updates are asked from both GPS and NETWORK together at the same time. whenever you get a location update of desired accuracy unregister from listening location updates.

    But if location updates are required frequently then calling GPS can be a KILLER OF BATTERY too so be careful of using GPS PROVIDER.

    GPS Updates are available good under open sky only. GPS Updates takes time , takes battery but Are More Accurate.

    Network Updates are quicker, consumes less battery but are comparatively less accurate. But if we are talking about a WIFI accuracy it will be near to 50 or 100 that can serve many real time requirement.

    It all depends on your requirement.

    0 讨论(0)
  • 2021-01-05 14:34

    Say, can I setup "request Location Update" for GPS_PROVIDER and NETWORK_PROVIDER (or PASSIVE_PROVIDER) to same function call like this:

    // SETUP Location Manager
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this);
    

    In this case, I get only GPS data.

    0 讨论(0)
提交回复
热议问题