一、創建一個空的android project;
二、assets下面創建www文件夾;
三、定位到下載的phonegap文件夾,將cordova.js拷貝到www文件夾下;將cordova-2.9.0.jar放入libs
四、將xml文件夾拷貝到res文件夾下;
五、www文件夾下新建index.html
六、Activity更改;
[html] view plaincopyprint?
1、import org.apache.cordova.DroidGap;
2、extends DroidGap
3、代替setContentView() 為 super.loadUrl("file:///android_asset/www/index.html");
七、AndroidManifest.xml更改:
1、
[html]
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
2、
[html] view plaincopyprint?
<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、
[html]
<activity
android:name="org.apache.cordova.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter></intent-filter>
</activity>