简体   繁体   English

如何在我们的android项目中使用phonegap插件

[英]How to use phonegap plugins in our android project

I need to use sms plugin in my android application on phonegap 我需要在phonegap上的android应用程序中使用sms插件

I've downloaded the required plugin also, I've changed all the instances of "phonegap" to "cordova" but I still get the error 我也下载了所需的插件,我已将“phonegap”的所有实例更改为“cordova”但我仍然收到错误

    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 你的phonegap js将采用以上形式

you can call the above js like 你可以调用上面的js之类的

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. 这里有一个适用于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)? 你的意思是如何在你的phonegap项目中使用插件,或者你想在你的android(工作室)项目中使用phonegap插件(如果你正在开发使用本机语言/ java使用Android工作室的Android应用程序)?

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 您还可以查看以下链接: http//javatechig.com/cross-platform/phonegap/phonegap-sms-plugin-android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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