1 phonegap.js 加入到项目。
2 phonegap.jar 加入到项目,变成奶瓶
3 模仿js 下载phonegap的源码,在资产目录底下。
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010-2011, IBM Corporation
*/
if (!PhoneGap.hasResource("")) {
PhoneGap.addResource("");
/**
* This class contains information about the current network Connection.
* @constructor
HM是我们自己定义的类
*/
var HM = function() {
};
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
HM 这个是我们定义的类
testLogin 是我们定义的方法
option是参数
*/
HM.prototype.testLogin = function(successCallback, errorCallback ,option) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
};
/**
*hmCommen 是我们自己定义的属性
*/
PhoneGap.addConstructor(function() {
if (typeof navigator.hmCommen === "undefined") {
HM.hmCommen = new Object();
}
});
}
4 在我们项目的入口处去继承 MainActivity extends DroidGap;
5 在res目录下面 ,需要把系统源码里面的配置文件复制过来
phonegap.xml我们不需要管。
plugins.xml我们需要配置
/**
*name 是service 配置的名字
value 具体的类名
*/
<plugin
name="HM_service"
value="com.example.hmphonegap.HmTest" />
========================================================
/**
*Network Status 这个是service的名字 需要跟plugins里面的name对应起来
getConnectionInfo 这个东西是action 具体调用哪个方法 android开发人员自己定义的类 HMTest2 extends Plugin
*/
HM.prototype.testLogin = function(successCallback, errorCallback ,option) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
};
2 phonegap.jar 加入到项目,变成奶瓶
3 模仿js 下载phonegap的源码,在资产目录底下。
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010-2011, IBM Corporation
*/
if (!PhoneGap.hasResource("")) {
PhoneGap.addResource("");
/**
* This class contains information about the current network Connection.
* @constructor
HM是我们自己定义的类
*/
var HM = function() {
};
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
HM 这个是我们定义的类
testLogin 是我们定义的方法
option是参数
*/
HM.prototype.testLogin = function(successCallback, errorCallback ,option) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
};
/**
*hmCommen 是我们自己定义的属性
*/
PhoneGap.addConstructor(function() {
if (typeof navigator.hmCommen === "undefined") {
HM.hmCommen = new Object();
}
});
}
4 在我们项目的入口处去继承 MainActivity extends DroidGap;
5 在res目录下面 ,需要把系统源码里面的配置文件复制过来
phonegap.xml我们不需要管。
plugins.xml我们需要配置
/**
*name 是service 配置的名字
value 具体的类名
*/
<plugin
name="HM_service"
value="com.example.hmphonegap.HmTest" />
========================================================
/**
*Network Status 这个是service的名字 需要跟plugins里面的name对应起来
getConnectionInfo 这个东西是action 具体调用哪个方法 android开发人员自己定义的类 HMTest2 extends Plugin
*/
HM.prototype.testLogin = function(successCallback, errorCallback ,option) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
};