1、phonegap到1.5版本便更名为cordova,所以应使用import org.apache.cordova.DroidGap替换import com.phonegap.*;
2、改变app icon
在AndroidManifest.xml中找到application,改变android:icon的值;若要改变应用名就改android:lable。
3、加载程序时定义背景
import org.apache.cordova.DroidGap;
import android.os.Bundle;
public class MainActivity extends DroidGap{
@override
public void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
super.setIntegerProperty("splashscreen",R.drawable.loading_icon); //Loading page icon
super.loadUrl("file:///android_asset/www/index.html");
}
}
4、全屏及去除标题栏
在AndroidManifest.xml中编辑activity,添加android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"。
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
5、报错reference error cannot find variable:你的js代码有误,请检查
pg camera json error:这是由于phonegap1.5版本将camera.getPicture函数缺省的destinationType值变为FILE_URI,而开发人员不小心错写为FILE_URL,故你要手工写入destinationType的值
navigator.camera.getPicture(onSuccess,onFail,{destinationType:Camera.DestinationType.FILE_URI});
6、为按钮添加事件
ducument.addEventListener("backbutton",backFunction,false);//返回键
document.addEventListener("menubutton",menuFunction,false);//菜单键
document.addEventListener("searchbutton",searchFunction,false);//搜索键
注销document.removeEventListener("backbutton",backFunction,false);