安卓GPS我的位置发现我的、位置、发现、GPS

由网友(太多的感情没有合适的表情)分享简介:我用this code 找到我的当前位置。但是,如果我在家里也找不到我。但是,谷歌地图和其他类似的应用程序都可以找到我,虽然我在家里。有什么区别?I'm using this code to find my current location. But if I'm at home it can't locate m...

我用this code 找到我的当前位置。但是,如果我在家里也找不到我。但是,谷歌地图和其他类似的应用程序都可以找到我,虽然我在家里。有什么区别?

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的工作原理与自由的天空(不是室内非常好)。因此,虽然谷歌地图可能会显示最后一个已知的位置,也许你的应用程序不。所以,你可能要开始打电话 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

代替,这是基于无线和/或GMS,比GPS较不准确,但工程室内

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

对于这一点,你需要的权限

For this, you need the permission

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

在你的清单。

阅读全文

相关推荐

最新文章