<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:anyDensity="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<title></title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"> </script>
<script type="text/javascript" charset="utf-8" src="test.js"> </script>
<script type="text/javascript"> function test1() { alert("HelloWorld"); navigator.hmCommen.test(successCallback,errorCallback,{}); } function testlogin(name,age) { //navigator.hmCommen.testLogin(successCallback,errorCallback,{}); navigator.hmCommen.testLogin(successCallback,errorCallback,{"name":name,"age":age}); } function successCallback() { alert("Success"); } function errorCallback() { alert("failed"); } function test2() { alert("hello world"); } </script>
</head>
<body>
<h1>Hello World</h1>
<button type="button" onclick="test2()">Hello Worold</button>
<button type="button" onclick="test1()">call me</button>
<button type="button" onclick="testlogin('abc',12)">login test</button>
</body>
</html>
/* * 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("hmCommen")) {
PhoneGap.addResource("hmCommen");
/** * This class contains information about the current network Connection. * @constructor */
var HmCommen = 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) */
HmCommen.prototype.test = function(successCallback, errorCallback,options) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "HM_service", "test", [options]);
};
HmCommen.prototype.testLogin = function(successCallback, errorCallback,options) {
// Get info
PhoneGap.exec(successCallback, errorCallback, "HM_service", "testLogin", [options]);
};
PhoneGap.addConstructor(function() {
if (typeof navigator.hmCommen === "undefined") {
navigator.hmCommen = new HmCommen();
}
});
}
<plugin name="HM_service" value="com.zj.phonegaptest.HMTest"/>
package com.zj.phonegaptest;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.widget.Toast;
import com.phonegap.api.*;
public class HMTest extends Plugin {
@Override
public PluginResult execute(String arg0, JSONArray arg1, String arg2) {
// TODO Auto-generated method stub
JSONObject arg=arg1.optJSONObject(0);
if(arg0.equalsIgnoreCase("test"))
{
return doTest();
}else if(arg0.equalsIgnoreCase("testLogin"))
{
try {
return testLogin(arg);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
private String name=null;
private int age=0;
PluginResult pluginResult=null;
private PluginResult testLogin(JSONObject arg) throws JSONException
{
name=(String)arg.get("name");
age=arg.getInt("age");
if("abc".equals(name))
{
pluginResult=new PluginResult(PluginResult.Status.OK);
}else
{
pluginResult=new PluginResult(PluginResult.Status.OK);
}
return pluginResult;
}
private PluginResult doTest()
{
pluginResult=new PluginResult(PluginResult.Status.OK);
return pluginResult;
}
}
phoneGap 基於android 實例 一 - china-orange - ITeye技術網站
http://lvjj.iteye.com/blog/1484479
PhoneGap開發環境搭建 - 隨機 - 博客園
http://www.cnblogs.com/Random/archive/2011/12/28/2305398.htmljavascript