Android:我可以通过哪些方式以编程方式获取当前位置

发布于 2024-10-31 22:10:44 字数 92 浏览 0 评论 0原文

我可以通过多少种方法在 Android 中以编程方式获取当前地理位置(纬度、朗度),哪种方法是最好、准确和更快的方法?

期待您的建议

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

街道布景 2024-11-07 22:10:44

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

德意的啸 2024-11-07 22:10:44

可以通过 IP 地址查找位置:

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

另一种方法是通过 GSM 或控制平面定位,但其他方法可以在此处找到:

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

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

多孤肩上扛 2024-11-07 22:10:44

在为 Android 开发位置感知应用程序时,您可以利用 GPS 和 Android 的网络位置提供程序来获取用户位置。尽管 GPS 最准确,但它只能在室外工作,会很快消耗电池电量,并且无法按照用户希望的速度返回位置。 Android 的网络位置提供程序使用手机信号塔和 Wi-Fi 信号确定用户位置,以在室内和室外工作、响应速度更快且使用更少电池电量的方式提供位置信息。要在应用程序中获取用户位置,您可以同时使用 GPS 和网络位置提供程序,或仅使用其中之一。

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);

                    }

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);

                    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文