当前位置:编程学习 > wap >>

Phonegap应用创建

一、创建一个空的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>  
 

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,