本文介绍了Android GPS 我的位置查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 此代码 查找我的当前位置.但如果我在家,它就找不到我.但是谷歌地图和其他类似的应用程序可以找到我,尽管我在家.有什么区别?

I'm using this code to find my current location. But if I'm at home it can't locate me. But google maps and another similar applications can locate me although I'm at home. What is difference?

推荐答案

如果您使用的是 GPS_Provider,请确保您在应用清单中具有以下权限:

If you're using the GPS_Provider, make sure that you have the following permission in your app manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

但通常 GPS 仅适用于空旷的天空(在室内不太好).因此,虽然 Google 地图可能会显示最后一个已知位置,但您的应用可能不会.因此,您可能希望最初调用 getLastKnowLocation 来设置初始标记.即使 GPS 无法修复,您仍然可以显示设备已知的最后一个已知位置,即您上次在户外的时间.

But usually GPS only works with a free sky (not indoors very well). Therefore while Google Maps might show the last known location, maybe your app doesn't. So you might want to initially call getLastKnowLocation initially to set the initial marker.Even though GPS cannot get a fix, you could still show the last known location known to the device, i.e. when you were outdoors last time.

作为 GPS_Provider 的替代或补充,您还可以使用

Alternatively or additionally to GPS_Provider, you could also use the

LocationManager.NETWORK_PROVIDER

相反,它基于 Wifi 和/或 GMS,不如 GPS 准确,但在室内工作.

instead,which is based on Wifi and/or GMS, is less accurate than GPS but works indoors.

为此,您需要权限

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

在您的清单中.

这篇关于Android GPS 我的位置查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:06