简体   繁体   中英

How to use phonegap plugins in our android project

I need to use sms plugin in my android application on phonegap

I've downloaded the required plugin also, I've changed all the instances of "phonegap" to "cordova" but I still get the error

    E/Web Console(2086): TypeError: Result of expression 
'window.plugins' [undefined] is not an object. at file:///android_asset/www/pluginexample.html:38

please give me link to any working project that uses plugin(any) so that I can know where I am getting this error

thanks!!!

var MyPlugin = function () {};

MyPlugin.prototype.mFunctionName = function (action , successCallback, failureCallback, arrVal) {    
    return PhoneGap.exec(successCallback, failureCallback,  "ClassName", 'maction',arrVal );
};

PhoneGap.addConstructor(function() {
    PhoneGap.addPlugin("mObject", new MyPlugin());
});

your phonegap js will be in above form

you can call the above js like

window.plugins.mObject.mFunctionName('maction',function(success){},function(error){});

or

var mObj =  new MyPlugin();

    mObj.mFunctionName('maction',function(success){},function(error){});

Here you have a working sms plugin for phonegap. You can either use it as it is or rewrite for your specific needs!

SMS Plugin

Do you mean how to use the plugin in your phonegap project or do you want to use phonegap plugin in your android (studio) project (If you are developing android apps with native langueage/java use android studio)?

The best way is from the plugin documentation. You can also check out this link : http://javatechig.com/cross-platform/phonegap/phonegap-sms-plugin-android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM