Take a look at my blog on how I defined the plugins. It is absolutely needed, as stated by "idiot", not being offense, it is just his nickname.
Also: Load that script as the very first one of all your scripts.
My blog: Android PhoneGap Toast plugin
Look at this part:
cordova.define("cordova/plugin/toasts", function (require, exports, module) {
var exec = require("cordova/exec");
module.exports = {
showShort: function (message, win, fail) {
exec(win, fail, "Toasts", "show_short", [message]);
},
showLong: function (message, win, fail) {
exec(win, fail, "Toasts", "show_long", [message]);
},
cancel: function (win, fail) {
exec(win, fail, "Toasts", "cancel", []);
}
};
});
And this part:
function toast(text,duration) {
var toasts = cordova.require("cordova/plugin/toasts");
if(duration=="short") {
toasts.showShort(text,
function() {
//console.log("PhoneGap Plugin: Toast short: callback success");
},
function() {
console.log("PhoneGap Plugin: Toast short: callback error");
});
} else if(duration=="long") {
toasts.showLong(text,
function() {
//console.log("PhoneGap Plugin: Toast long: callback success");
},
function() {
console.log("PhoneGap Plugin: Toast long: callback error");
});
} else {
toasts.cancel(
function() {
//console.log("PhoneGap Plugin: Toast cancel: callback success");
},
function() {
console.log("PhoneGap Plugin: Toast cancel: callback error");
});
}
}
Replace the plugin name (toasts) with your own, and don't forget the commands (showShort, etc) that has to be replaced with your own.
Also look at the documentation: PhoneGap docs 2.7.0