通过在PhoneGap的应用config.xml中配置的Andr​​oid意图 [英] configure android intents via config.xml in phonegap app

查看:187
本文介绍了通过在PhoneGap的应用config.xml中配置的Andr​​oid意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个PhoneGap的,并想用意图的机器人。当我添加以下的Andr​​oidManifest.xml(平台/ Android的范围内)它像预期的。

I am developing a phonegap and would like to use intents for android. When I add the following to AndroidManifest.xml (within platforms/android) it works like expected.

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="*mysite.com" />
    <data android:host="*mysite.de" />
</intent-filter>

现在我想知道如何不通过AndroidManifest.xml中,而是通过下WWW config.xml文件/配置这个自成据我了解AndroidManifest.xml文件可能会在构建过程中被覆盖,config.xml文件是像这样的东西的好地方。我尝试以下(含各种变体):

Now I would like to know how to configure this not via AndroidManifest.xml but via config.xml under www/ since as far as i understand the AndroidManifest.xml file might be overwritten during the build process and the config.xml is the right place for stuff like this. I tried the following (including all kinds of variations):

<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
         <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:host="*mysite.de" />
            <data android:host="*mysite.com" />
        </intent-filter>
    </config-file>
</platform>

...不幸的是,这将始终会导致以下错误:

...unfortunately this will always result in the following error:

 [echo] ----------
 [echo] Handling Resources...
 [aapt] Found modified input file
 [aapt] Generating resource IDs...
 [aapt] /home/.../platforms/android/res/xml/config.xml:30: error: Error parsing XML: unbound prefix

任何想法是AP preciated,我搜索的网页超过一个小时。

Any idea is appreciated, I searched the web for over an hour.

我的PhoneGap的版本是3.5.0-0.21.18

My phonegap version is 3.5.0-0.21.18

推荐答案

使用旧版本的科尔多瓦3,AndroidManifest.xml中的更新被保留。我开始与3.5版本的惊喜,当他们增加更多的选择与preference标签。

With older versions of cordova 3, androidmanifest.xml updates were kept. I started to have surprises with version 3.5 when they added more options with the preference tag.

例如,我曾经通过更新AndroidManifest.xml中配置AndroidLaunchMode,现在他们增加了一个选项,以允许该配置config.xml中这令,升级科尔多瓦CLI后,我的设置disapeared,直到我意识到发生了什么事情。

For example, I used to configure AndroidLaunchMode by updating AndroidManifest.xml and now they added an option to allow this configuration in config.xml which made that after upgrading cordova cli, my setting disapeared untill I realised what was going on.

目前,科尔多瓦prepare机器人不会删除你的意图过滤器,这样就意味着与科尔多瓦的当前版本,你会失去你的改变只有当你除去Android平台或者升级到较新的Andr​​oid科尔多瓦这将允许这样的配置。

For the moment, cordova prepare android will not delete your intent filter, so that means that with current build of cordova you will loose your changes only if you remove the android platform or you upgrade to a newer cordova android which would allow such configuration.

如果你想确保不丢失此设置,您可以写后prepare一个钩子来更新AndroidManifest.xml中。

If you want to be sure not to loose this setting, you may write a hook in post-prepare to update AndroidManifest.xml.

或者你可以做一个插件,只会更新AndroidManifest.xml中(你想使用的配置文件的语法似乎更plugin.xml的语法)。

Or you could make a plugin that would only update AndroidManifest.xml (the config-file syntax you're trying to use seems to be more plugin.xml syntax).

这篇关于通过在PhoneGap的应用config.xml中配置的Andr​​oid意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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