I am trying to use webintents with a cordova app to be able to send images from another app to mine.
I am using cordova 5.1.1 and added the following plugins to my android platform project:
com.virtualartifacts.webintent 1.0.0 "WebIntent"
cordova-plugin-camera 1.1.0 "Camera"
cordova-plugin-console 1.0.0 "Console"
cordova-plugin-device 1.0.0 "Device"
cordova-plugin-file 2.0.0 "File"
cordova-plugin-file-transfer 1.1.0 "File Transfer"
cordova-plugin-whitelist 1.0.0 "Whitelist"
The index.html file for the project looks like:
<!DOCTYPE html>
<html>
<head>
<title>WebIntent Test</title>
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<script src="cordova.js"></script>
<script src="js/webintent.js"></script>
<script>
function init() {
document.addEventListener("deviceready",deviceReady,false);
}
function deviceReady() {
console.log("App started. Device ready");
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_STREAM,
function(data) {
console.log(data); // which never gets called
}, function(e) {
console.log(e);
// I simply get the message "Error"
});
}
</script>
</head>
<body onload="init()">
<h1>Demo WebIntent</h1>
</body>
</html>
so nothing really special here. after searching the net for a while I found some information about the webintent plugin being buggy (as mentioned here on SO. So i found the patched version and double checked that the right code is in the WebIntent.java file, which is.
I also added the intent-filter tags in the AndroidManifest.xml file like so:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
When i installed the app on the device and try to share an Image my app shows up in the list of apps that are able to handle this sharing, and i also get the "App started..." text, so I know it gets called.
But no matter what kind of image i try i always reach the "error" part of the getExtra method and my console.log only shows "Error". Debugging is done directly on the device via GapDebug.
Is there anything I am missing or has anyone an idea on making my app getting images from other apps to work with?
Thanks in advance!