android中的phonegap构建权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23387007/
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
phonegap build permissions in android
提问by digicom
I'm using phonegap build to create my app.
我正在使用 phonegap build 来创建我的应用程序。
Is there a way I can configure the permissions asked by android?
有没有办法可以配置android要求的权限?
For now it asks for all the permissions when I actually only need internet, localstorage and notifications.
现在,当我实际上只需要互联网、本地存储和通知时,它会要求所有权限。
Please bare in mind - I'm only using phonegap build, Not CLI and not Cordova. I have no AndroidManifest.xml only config.xml
请记住 - 我只使用 phonegap build,而不是 CLI 而不是 Cordova。我没有 AndroidManifest.xml 只有 config.xml
Can anybody help?
有人可以帮忙吗?
Thanks.
谢谢。
Edit:
编辑:
This was answered by SvenT23.
这是由 SvenT23 回答的。
We both realized that phonegap has removed this answer from their current docs and left it only in the old docs.
我们都意识到 phonegap 已经从他们当前的文档中删除了这个答案,只将它留在了旧文档中。
For future reference I'm adding the instructions from phonegap in case it will get deleted in the future.
为了将来参考,我正在添加来自 phonegap 的说明,以防将来它会被删除。
API Features
API 特性
Currently supported through this interface are the following feature names:
http://api.phonegap.com/1.0/battery
// maps to android:BROADCAST_STICKY permissionhttp://api.phonegap.com/1.0/camera
// maps to android:CAMERA, winphone:ID_CAP_ISV_CAMERA, and winphone:ID_HW_FRONTCAMERA permissionshttp://api.phonegap.com/1.0/contacts
// maps to android:READ_CONTACTS, android:WRITE_CONTACTS, android:GET_ACCOUNTS, and winphone:ID_CAP_CONTACTS permissionshttp://api.phonegap.com/1.0/file
// maps to WRITE_EXTERNAL_STORAGE permissionhttp://api.phonegap.com/1.0/geolocation
// maps to android:ACCESS_COARSE_LOCATION, android:ACCESS_FINE_LOCATION, android:ACCESS_LOCATION_EXTRA_COMMANDS, and winphone:ID_CAP_LOCATION permissionshttp://api.phonegap.com/1.0/media
// maps to android:RECORD_AUDIO, android:RECORD_VIDEO, android:MODIFY_AUDIO_SETTINGS, and winphone:ID_CAP_MICROPHONE permissionshttp://api.phonegap.com/1.0/network
// maps to android:ACCESS_NETWORK_STATE, and winphone:ID_CAP_NETWORKING permissionshttp://api.phonegap.com/1.0/notification
// maps to VIBRATE permissionhttp://api.phonegap.com/1.0/device
// maps to winphone:ID_CAP_IDENTITY_DEVICE permission
目前通过此接口支持以下功能名称:
http://api.phonegap.com/1.0/battery
// 映射到 android:BROADCAST_STICKY 权限http://api.phonegap.com/1.0/camera
// 映射到android:CAMERA, winphone:ID_CAP_ISV_CAMERA, and winphone:ID_HW_FRONTCAMERA 权限http://api.phonegap.com/1.0/contacts
// 映射到 android:READ_CONTACTS、android:WRITE_CONTACTS、android:GET_ACCOUNTS 和 winphone:ID_CAP_CONTACTS 权限http://api.phonegap.com/1.0/file
// 映射到 WRITE_EXTERNAL_STORAGE 权限http://api.phonegap.com/1.0/geolocation
// 映射到 android:ACCESS_COARSE_LOCATION、android:ACCESS_FINE_LOCATION、android:ACCESS_LOCATION_EXTRA_COMMANDS 和 winphone:ID_CAP_LOCATION 权限http://api.phonegap.com/1.0/media
// 映射到 android:RECORD_AUDIO、android:RECORD_VIDEO、android:MODIFY_AUDIO_SETTINGS 和 winphone:ID_CAP_MICROPHONE 权限http://api.phonegap.com/1.0/network
// 映射到android:ACCESS_NETWORK_STATE,和winphone:ID_CAP_NETWORKING 权限http://api.phonegap.com/1.0/notification
// 映射到 VIBRATE 权限http://api.phonegap.com/1.0/device
// 映射到 winphone:ID_CAP_IDENTITY_DEVICE 权限
Example Usage
示例用法
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.phonegap.example"
versionCode = "10"
version = "1.0.0" >
<!-- versionCode is optional and Android only -->
<name>PhoneGap Example</name>
<description>
An example for phonegap build docs.
</description>
<author href="https://build.phonegap.com" email="[email protected]">
Hardeep Shoker
</author>
<!--
If you do not want any permissions to be added to your app, add the
following tag to your config.xml; you will still have the INTERNET
permission on your app, which PhoneGap requires.
-->
<preference name="permissions" value="none"/>
<!-- to enable individual permissions use the following examples -->
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
</widget>
采纳答案by SvenT23
A quick bit of googling returns the <feature>
element to set permissions. Combined with <preference name="permissions" value="none"/>
it should be exactly what you're looking for.
快速使用谷歌搜索返回<feature>
设置权限的元素。结合<preference name="permissions" value="none"/>
它应该正是你正在寻找的。
http://docs.phonegap.com/phonegap-build/configuring/#Features
http://docs.phonegap.com/phonegap-build/configuring/#Features