不动找位置,目前最好的方法?

Finding location without moving, currently the best way?

是否有关于如何在 Android 应用程序中获取当前位置的更新教程?我已经尝试了我遇到的任何可能的情况,但我似乎无法找到获取 Android GPS 位置的解决方案。使用 getLastKnownLocation() 方法和 requestLocationUpdates() 在许多不同的帖子上建议的路线总是返回空引用。那么关于目前最好的做法有什么建议吗?

如果关闭位置提供程序,

requestLocationUpdates 将 return 为空。通常最好同时检查 getLastKnownLocation(LocationManager.GPS_PROVIDER)lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) 以查看其中一个是否不为空。