Android : How may ways I can get current location programatically

牧云@^-^@ 提交于 2019-12-08 07:33:03

问题


How many ways I can get the current geo location (lat,lang) programatically in Android, Which is the best, accurate and faster way??

Look forward to your suggestions

Thanks


回答1:


You should read Obtaining User Location in the SDK's documentation.




回答2:


It is possible to find out location via IP address:

http://www.google.com.sg/search?aq=1&oq=identifying+location&sourceid=chrome&ie=UTF-8&q=identifying+location+of+ip+addresses

Another method is by GSM, or control-plane locating, yet other methods can be found here:

http://en.wikipedia.org/wiki/Location-based_service#Others




回答3:


When developing a location-aware application for Android, you can utilize GPS and Android's Network Location Provider to acquire the user location. Although GPS is most accurate, it only works outdoors, it quickly consumes battery power, and doesn't return the location as quickly as users want. Android's Network Location Provider determines user location using cell tower and Wi-Fi signals, providing location information in a way that works indoors and outdoors, responds faster, and uses less battery power. To obtain the user location in your application, you can use both GPS and the Network Location Provider, or just one`

locationManager.requestLocationUpdates(
                                LocationManager.GPS_PROVIDER,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                        Log.d("GPS Enabled", "GPS Enabled");
                        if (locationManager != null) {
                            loc = locationManager
                                    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                          }
locationManager.requestLocationUpdates(
                            LocationManager.NETWORK_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("Network", "Network");
                    if (locationManager != null) {
                        loc = locationManager
                                .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

                    }


来源:https://stackoverflow.com/questions/5662333/android-how-may-ways-i-can-get-current-location-programatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!