如何添加“使用权限"一个Cordova项目的AndroidManifest.xml标签? [英] How do I add "uses-permissions" tags to AndroidManifest.xml for a Cordova project?

查看:415
本文介绍了如何添加“使用权限"一个Cordova项目的AndroidManifest.xml标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据您添加的cordova插件,一些<uses-permission>条目会自动添加到AndroidManifest.xml中.但是,我需要<uses-permission android:name="android.permission.INTERNET" />权限,该权限不会自动添加.

Some <uses-permission> entries are added automatically to AndroidManifest.xml, based on cordova plugins that you add. However, I need the <uses-permission android:name="android.permission.INTERNET" /> permission, which isn't added automatically.

我可以将其直接添加到AndroidManifest.xml中,但是下次我运行cordova build时它将被覆盖,并且我不想一直重复添加它...

I can add that directly to AndroidManifest.xml, but it will get overwritten the next time I run cordova build, and I don't want to have to keep re-adding it...

我确定(在config.xml或其他地方)有一种指定权限的科多瓦"方式,但是在

I'm sure there's a "Cordova" way of specifying permissions (in config.xml, or elsewhere), but I'm not seeing it in their documentation anywhere...

那么,指定用户权限的科多瓦方式"是什么?

So, what is the "Cordova way" of specifying user permissions?

推荐答案

据我所知,每次运行cordova build时,不会生成AndroidManifest.xml.添加/删除插件时,将对其进行相应的修改.但是,如果您添加自己的权限,它将不会被删除(除非有冲突).

As I know AndroidManifest.xml will not be generated every time when you run cordova build. When you add/remove a plugin it will be modified accordingly. But if you add your own permissions it will not be removed(Unless there is a conflict).

由于权限是特定于Android(平台)的,因此,您只需要将其添加到 AndroidManifest.xml 文件中即可.

Since the permissions are Android (platform) specific, in your case you have to add it into the AndroidManifest.xml file only.

即使在任何插件的plugin.xml中,它们也会添加权限,如下所示:

Even in plugin.xml of any plugin they add permission as shown :

<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.INTERNET"/>
    </config-file>
</platform>

其中说在插件安装时将"uses-permission"行添加到AndroidManifest.xml文件中.但是您不能在config.xml文件中提及这一点.

Which says add uses-permission line to AndroidManifest.xml file at the installation time of plugin. But you cant mention this in config.xml file.

同样不要忘记将此属性放在应用程序的根文件夹中的 config.xml 文件中的根小部件元素中,如@hiddentao在评论中说的那样.

Also don't forget to put this attribute in the root widget element present in the config.xml file,located in the root folder of the app, as @hiddentao said in a comment.

config.xml

<widget
  xmlns:android="http://schemas.android.com/apk/res/android"
  ...>

这篇关于如何添加“使用权限"一个Cordova项目的AndroidManifest.xml标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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