Basic use of PhoneGap in Android development

Source: Internet
Author: User

First, about PhoneGap

PhoneGap is an open-source development framework designed to enable developers to develop cross-platform mobile applications using Web APIs such as HTML, Javascript, and CSS.

Second, PhoneGap in the Android environment to build

1. Make sure the Android development environment is installed on your computer, and download the corresponding version of the ZIP package on the PHONEGAP official website (www.phoneGap.com).

Click here to download PhoneGap1.4.0

2. Create an Android project.

3. Unzip the ZIP package that you just downloaded, add the. jar file in the/lib/android to the Libs folder in the project engineering, and then perform the action to add the. jar package. :

Add the completed Project catalog:

4. Create a new folder under the Project Directory Assets folder, name is WWW, add the. js file from the/lib/android in the downloaded zip package.

5. Add the appropriate permissions in the Androidmainfest.xml file:

<supports-screens
Android:largescreens= "true"
Android:normalscreens= "true"
Android:smallscreens= "true"
Android:xlargescreens= "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.INTERNET"/>
<uses-permission android:name= "Android.permission.RECEIVE_SMS"/>
<uses-permission android:name= "Android.permission.RECORD_AUDIO"/>
<uses-permission android:name= "Android.permission.RECORD_VIDEO"/>
<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"/>

<uses-feature android:name= "Android.hardware.camera"/>
<uses-feature android:name= "Android.hardware.camera.autofocus"/>

6. Create a file in the/assets/www directory index.html

7. In the project res directory download, create a new folder named XML, the downloaded Zip package/lib/android/xml in the Phonegap.xml and plugins.xml add in.

8. Mainactivity.java to inherit droidgap and modify protected void OnCreate (bundle savedinstancestate) to public void onCreate (bundle Savedinstancestate). and load the index.html through the code.

9. Publish the program to the emulator.

Third, the demo project download

Click I download demo

Basic use of PhoneGap in Android development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.