Saturday, 17 August 2013

Cordova 2.1.0 plugin

Cordova 2.1.0 plugin

I have a problem creating a plugin in Cordova 2.1.0 for Android.
I have:
config.xml
<plugin name="setWallpaperPlugin"
value="com.thotdev.fondosanime.SetWallpaperPlugin" />
plugin.js
window.setWallpaperPlugin = function (ms, successCallback, failureCallback) {
return cordova.exec(successCallback, failureCallback,
'setWallpaperPlugin', "setWallPaper", [ms]);
};
In html:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$("#setwall").click(function() {
alert("ahi voy!");
window.plugins.setWallpaperPlugin.set(srcimg,
function () {
navigator.notification.alert("OK!");
}
);
});
};
I have jquery and execute alert when push the button, but I have this error:
Uncaught TypeError: Cannot read property 'setWallpaperPlugin' of undefined
at file: ///android_asset/www/fondo.html
Can anyone help me please?

No comments:

Post a Comment