获得最准确的GPS位置

时间:2011-12-15 17:08:35

标签: android gps

如果我的应用在打开后立即开始更新GPS位置,该怎么办?

现在我有了这段代码:

locationManager.requestLocationUpdates(bestProvider,0 ,0, loc_listener);
location = locationManager.getLastKnownLocation (bestProvider);

哪个位置最佳。我在手机上运行我的应用程序,它从我今天早些时候的位置获得了位置。

我希望我的应用在首次打开时更新gps位置。

我一直在看这些主题:

What is the simplest and most robust way to get the user's current location on Android? Android find GPS location once, show loading dialog

但我无法连接所有内容。

1 个答案:

答案 0 :(得分:1)

如果我没弄错,你需要设置一个监听器并覆盖onLocationChanged方法。这应该是你的下一个GPS位置,即坐锁后的位置。

本教程应说明我试图说的内容:http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2

如果我错了StackOverflow,请阻止我,我对此不确定。

相关问题