我是cordova的新手,我正在开发一个插件,我希望我的用户将值(例如regID和regPass)传递给本机,我希望立即完成初始化函数的调用。 这是我想用来处理来自js
的请求的函数public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
}
我的js文件看起来像这样
var app = {
// Application Constructor
initialize: function() {
console.log('initialize function is called: ');
this.init();
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
function init(){
var regId="userid";
var regPass= "password";
var initArray = new Array(regId,regPass);
var init = MyPlugin.init("init",initArray);
init.done(function(response){
console.log("initialization on going...");
});
init.fail(function (response) {
console.log(response);
});
}
};
app.initialize();
但我不知道如何从原生android方面的initialize方法接收值(regId和Pass),我将感谢任何帮助正确的方向,无论是教程还是博客文章