Skip to content Skip to sidebar Skip to footer

Configure Android Intents Via Config.xml In Phonegap App

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.

Solution 1:

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.

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.

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.

If you want to be sure not to loose this setting, you may write a hook in post-prepare to update AndroidManifest.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).

Solution 2:

I was facing the exact same problem. I had to use hooks as a workaround, never managed to get it right from the config.xml file itself.

I documented what I did in this anwser. I hope this helps !

Solution 3:

I managed to get this to work by adding the necessary entries within the plugin.xml file for the web intents plugin.

I.e. add this:

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

to this file:

/plugins/com-darryncampbell-cordova-plugin-intent/plugin.xml

You should already have an "<intent-filter>" tag that was added when you installed the plugin. If you're using the plugin from darryncampbell (which is the currently referenced "official" plugin for webintents from Ionic) then you'll see it as the <intent-filter> that's referenced with the attribute android:name="com.darryncampbell.cordova.plugin.intent.ACTION".

Add your new intent filter directly below that one.

The downside of this approach is that you'll likely need to re-enter the details if you reinstall the plugin. I could not get it to work by adding the entries in config.xml though.

Post a Comment for "Configure Android Intents Via Config.xml In Phonegap App"