ADT Integrated Environment + PhoneGap 2.9.0 build HTML5 development APP environment, phonegaphtml5

Source: Internet
Author: User

ADT Integrated Environment + PhoneGap 2.9.0 build HTML5 development APP environment, phonegaphtml5

 I.Environment Construction


1. build and develop the Android environment, which is not described here. You can use the ADT integrated environment or Eclipse + Android SDK + ADT Plugin.

ADT integrated environment: http://developer.android.com/sdk/index.html


2. Configure PhoneGap

PhoneGap: http://phonegap.com/install/

This document is not applicable to versions earlier than the phonegap-2.9.0, because some of the following files are not found in the phonegap-2.9.0.


2.1 create an Android project.


2.2 copy the jar file in the android directory under the PhoneGap directory to the libs directory of the project.



2.3 copy the xml directory to the res directory of the project.



2.4 create a www directory under the assets Directory and put the html content below. For testing, we copied the content in the phonegap example.



2.5 modify the Activity code of the newly created Android project.


Modify the code to the following code:

<span style="font-family:Times New Roman;">importandroid.os.Bundle;importorg.apache.cordova.*; publicclass MainActivity extends DroidGap{    @Override    public void onCreate(BundlesavedInstanceState)    {        super.onCreate(savedInstanceState);        // Set by <contentsrc="index.html" /> in config.xml        //super.loadUrl(Config.getStartUrl());       super.loadUrl("file:///android_asset/www/index.html")    }}</span>

Note:

MainActivity inherits DroidGap and then imports the package where the DroidGap class is located, that is, import org. apache. cordova. *; then calls the html file under the assets/www directory in OnCreate.


2.6 modify AndroidManifest. xml of the Android Project


Modify as follows:

<span style="font-family:Times New Roman;"><manifestxmlns:android="http://schemas.android.com/apk/res/android"    package="com.lilu.helloworld"   android:hardwareAccelerated="true"    android:versionCode="1"    android:versionName="1.0"   android:windowSoftInputMode="adjustPan" >     <supports-screens        android:anyDensity="true"        android:largeScreens="true"        android:normalScreens="true"        android:resizeable="true"        android:smallScreens="true"        android:xlargeScreens="true"/>     <uses-permissionandroid:name="android.permission.CAMERA" />    <uses-permissionandroid:name="android.permission.VIBRATE" />    <uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" />    <uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" />    <uses-permissionandroid:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>    <uses-permissionandroid:name="android.permission.INTERNET" />    <uses-permissionandroid:name="android.permission.RECEIVE_SMS" />    <uses-permissionandroid:name="android.permission.RECORD_AUDIO" />    <uses-permissionandroid:name="android.permission.RECORD_VIDEO" />    <uses-permissionandroid:name="android.permission.MODIFY_AUDIO_SETTINGS" />    <uses-permissionandroid:name="android.permission.READ_CONTACTS" />    <uses-permissionandroid:name="android.permission.WRITE_CONTACTS" />    <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />    <uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" />    <uses-permissionandroid:name="android.permission.GET_ACCOUNTS" />    <uses-permission android:name="android.permission.BROADCAST_STICKY"/>     <application        android:debuggable="true"       android:hardwareAccelerated="true"       android:icon="@drawable/ic_launcher"       android:label="@string/app_name" >        <activity            android:name="com.lilu.helloworld.MainActivity"           android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"           android:label="@string/app_name"           android:theme="@android:style/Theme.Black.NoTitleBar" >            <intent-filter>                <actionandroid:name="android.intent.action.MAIN" />                 <categoryandroid:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>     <uses-sdk        android:minSdkVersion="7"        android:targetSdkVersion="17"/> </manifest></span>

You have added some application permissions. Change the package under the <manifest> label to the package name of your application, and change the Activity name to your own Activity class.

The above completes the configuration of PhoneGap. If the Android program is successfully run, you can see the data on the html page.

Then write the html page you need.

Ii. Reference URL

1. http://www.cnblogs.com/kingofpop/articles/3249845.html

2. http://www.cnblogs.com/Random/archive/2011/12/28/2305398.html

Related Article

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.