一、创建一个空的android project;
二、assets下面创建www文件夹;
三、定位到下载的phonegap文件夹,将cordova.js拷贝到www文件夹下;将cordova-2.9.0.jar放入libs
四、将xml文件夹拷贝到res文件夹下;
五、www文件夹下新建index.html
六、Activity更改;
1、import org.apache.cordova.DroidGap; 2、extends DroidGap 3、代替setContentView() 为 super.loadUrl("file:///android_asset/www/index.html");
七、AndroidManifest.xml更改:
1、
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:anyDensity="true" />
2、
<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" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" />
3、activity添加属性:android:configChanges="orientation|keyboardHidden"
4、
<activity android:name="org.apache.cordova.DroidGap" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden"> <intent-filter></intent-filter> </activity>
详情:http://www.adobe.com/devnet/html5/articles/getting-started-with-phonegap-in-eclipse-for-android.html