phonegap build权限在android [英] phonegap build permissions in android

查看:177
本文介绍了phonegap build权限在android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用phonegap build创建我的应用程序。



有没有办法配置android请求的权限?



现在,当我只需要互联网,本地存储和通知时,它会询问所有权限。



请记住 - 我只是使用phonegap构建,不是CLI,而不是Cordova。
我没有AndroidManifest.xml只有config.xml



有人可以帮助吗?





编辑



这是由SvenT23回答的。



我们都意识到,phonegap已经从他们当前的文档中删除了这个答案,只留在旧的文档中。





API功能


目前通过此界面支持以下功能名称:



http://api.phonegap.com/1.0/battery

//映射到android:BROADCAST_STICKY权限



http://api.phonegap.com/1.0/camera

// maps to android:CAMERA,winphone:ID_CAP_ISV_CAMERA,and winphone:ID_HW_FRONTCAMERA permissions



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权限


使用示例

 <?xml version =1.0encoding =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是可选的,仅限Android - >

< name> PhoneGap示例< / name>

< description>
phonegap构建文档的示例。
< / description>

< author href =https://build.phonegap.comemail =support@phonegap.com>
Hardeep Shoker
< / author>

<! -
如果您不想将任何权限添加到您的应用程序,请将
以下标记添加到您的config.xml;你仍然会有你的应用程序的INTERNET
权限,PhoneGap要求。
- >
< preference name =permissionsvalue =none/>

<! - 要启用单个权限,请使用以下示例 - >
< 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>


解决方案

c>< feature> 元素来设置权限。结合< preference name =permissionsvalue =none/> 它应该是你要找的。

http://docs.build.phonegap.com/en_US /2.9.0/configuring_features.md.html


I'm using phonegap build to create my app.

Is there a way I can configure the permissions asked by 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

Can anybody help?

Thanks.

Edit:

This was answered by SvenT23.

We both realized that phonegap has removed this answer from their current docs and left it only in the old docs.

For future reference I'm adding the instructions from phonegap in case it will get deleted in the future.

API Features

Currently supported through this interface are the following feature names:

http://api.phonegap.com/1.0/battery
// maps to android:BROADCAST_STICKY permission

http://api.phonegap.com/1.0/camera
// maps to android:CAMERA, winphone:ID_CAP_ISV_CAMERA, and winphone:ID_HW_FRONTCAMERA permissions

http://api.phonegap.com/1.0/contacts
// maps to android:READ_CONTACTS, android:WRITE_CONTACTS, android:GET_ACCOUNTS, and winphone:ID_CAP_CONTACTS permissions

http://api.phonegap.com/1.0/file
// maps to WRITE_EXTERNAL_STORAGE permission

http://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 permissions

http://api.phonegap.com/1.0/media
// maps to android:RECORD_AUDIO, android:RECORD_VIDEO, android:MODIFY_AUDIO_SETTINGS, and winphone:ID_CAP_MICROPHONE permissions

http://api.phonegap.com/1.0/network
// maps to android:ACCESS_NETWORK_STATE, and winphone:ID_CAP_NETWORKING permissions

http://api.phonegap.com/1.0/notification
// maps to VIBRATE permission

http://api.phonegap.com/1.0/device
// maps to winphone:ID_CAP_IDENTITY_DEVICE permission

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="support@phonegap.com">
        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>

解决方案

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.

http://docs.build.phonegap.com/en_US/2.9.0/configuring_features.md.html

这篇关于phonegap build权限在android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆