1, phonegap configuration description:
- Download PhoneGap source code, and then unzip directly. The version I downloaded is the PhoneGap2.9.0 version, and the following steps are made in this version, which may be slightly different for other versions.
- Create a new folder under the Android project directory asserts www,. Then copy the Cordova1.js (the downloaded PhoneGap version) of the phonegap/lib/android directory to the WWW directory you just created.
- Copy the Cordova-2.9.0.jar file into the Libs folder. :
- The XML folder in the PhoneGap is copied to the Res folder in the project directory.
- Create the index.html file under/assets/www (this file has an HTML sample file in the PhoneGap decompression file asserts), and link the PhoneGap JS file, such as:
- Make the following changes to the Xxx.java file under the SRC folder (this is not necessarily the case, just click on the Red Fork on the left side of the error):
1) Modify the inheritance of the class to change the activity to Droidgap;
2) Replace the Setcontentview () line with the Super.loadurl ("file:///android_asset/www/index.html");
3) Change the OnCreate class from protected to public property;
4) need to add import org.apache.cordova.DroidGap; Take my file as an example, as follows:
- Right-click on the Androidmanifest.xml file under the project root and select Open with > Text Editor (open by), add the following Please refer to the Androidmanifest.xml file under the PhoneGap-2.9.0 folder for specific additions.
<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"/>
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
Run as Android application, the results are as follows: So far, the PhoneGap configuration is complete, this is a small application implemented.
2, PhoneGap API application Example:
Here, the camera object with PhoneGap provides access to the device's default camera application. The method is amera.getpicture detailed code as follows: file index.html<! DOCTYPE html>
3. Plug-in application exampleCond
PHONEGAP Configuration Instructions &&phonegap API application Example && Plugin application Example