Android 位置权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21358392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android location permissions
提问by Samantha Withanage
In my Androidapplication I'm willing to use GPS locations.
在我的Android应用程序中,我愿意使用GPS 位置。
- What are the main permissionsthat I should included in android manifestfile in order to use GPS locations.
- In case of lost the GPS signalstrength, is there any way to triangulatethe position using mobile networks.
- 为了使用 GPS 位置,我应该在android 清单文件中包含哪些主要权限。
- 如果GPS 信号强度丢失,有没有办法使用移动网络进行三角定位。
Thank you!
谢谢!
回答by Jems
The main permissions you need are android.permission.ACCESS_COARSE_LOCATION
or android.permission.ACCESS_FINE_LOCATION
.
您需要的主要权限是android.permission.ACCESS_COARSE_LOCATION
或android.permission.ACCESS_FINE_LOCATION
。
Only fine location will allow you access to gps data, and allows you access to everything else coarse location gives. You can use the methods of the LocationManagerto acquire location data from gps and cell tower sources already, you do not have to work out this information yourself.
只有精细位置才能让您访问 GPS 数据,并允许您访问粗略位置提供的所有其他内容。您可以使用LocationManager的方法从 GPS 和手机信号塔源获取位置数据,您不必自己计算这些信息。
If you are targeting API Level 21 (5.0) or higher, you may also need this:
如果您的目标是 API 级别 21 (5.0) 或更高,您可能还需要:
<uses-feature android:name="android.hardware.location.gps" />
回答by The Creator
This permission should allow your app to use location services through the devices GPS, wifi, and cell towers. Just plop it in your manifest wherever you put your permissions, and it should do the trick. You can find all the other permissions here: (http://developer.android.com/reference/android/Manifest.permission.html)
此权限应允许您的应用通过设备 GPS、wifi 和手机信号塔使用定位服务。只需将其放入清单中您放置权限的任何位置,它就可以解决问题。您可以在此处找到所有其他权限:(http://developer.android.com/reference/android/Manifest.permission.html)
Here is the code:
这是代码:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
回答by Garfield Heron
I had the same issue and noticed that the code was requesting high accuracy but the manifest had course permissions. I changed it to fine and the error no longer occurs.
我遇到了同样的问题,并注意到代码要求高精度,但清单具有课程权限。我把它改成罚款,错误不再发生。
Make sure the code and the manifest reflect the same level of accuracy requested and allowed.
确保代码和清单反映了要求和允许的相同级别的准确性。
So if the manifest has android.permission.ACCESS_FINE_LOCATION the application can request geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high...
因此,如果清单具有 android.permission.ACCESS_FINE_LOCATION,则应用程序可以请求 geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high...