PhoneGap Development Guide Series (3)----Android development environment built in eclipse

Source: Internet
Author: User

Prerequisites: The Android SDK and ADT have been installed in eclipse.

1. Download PhoneGap, unzip.

2. Create a new Android project with Eclipse.

3. Copy the Phonegap-1.0.0.js from the Android folder in the PhoneGap unzip package to the/assets/www/directory of the Android project.

4. Copy the Phonegap-1.0.0.jar from the Android folder in the PhoneGap unzip package to the/libs directory of the Android project.

5. Create a new index.html in the/assets/www/directory with the following contents:

<! DOCTYPE html>

<title>PhoneGap</title>

<script type= "Text/javascript" charset= "Utf-8" src= "Phonegap-1.0.0.js" ></script>

<body>

</body>

6. Copy the following configuration permissions XML to the <application> label of the Androidmanifest.xml file.


<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"/>
<supports-screens
Android:anydensity= "true"
Android:largescreens= "true"
Android:normalscreens= "true"
Android:resizeable= "true"
Android:smallscreens= "true"/>

7. Add the following to the Activity tab of the Androidmanifest.xml file:

Android:configchanges= "Orientation|keyboardhidden

This is to ensure that the machine does not re-execute the activity's OnCreate method when switching between the two screens.

8. Locate the Libs directory in the newly created Android project and right-click on the Phonegap-1.0.0.jar and select Build Path->add to build Path.

9. Modify the Mainactivty in Android so that it inherits to Droidgap and modify its OnCreate method as follows:

public class Mainactivity extends Droidgap {

@Override public void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate); Super.oncreate (savedinstancestate);

Super.loadurl ("file:///android_asset/www/index.html");

}

10.OK, now running the Android project, you can see the content of the index.html we just built.

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.