安装
sudo npm install -g cordova
cordova create AppName
cordova platform add browser
cordova run browser
cordova platform add android --save
cordova platform ls
cordova requirements
编译
cordova build android
cordova build android -release
cordova emulate android
配置XML
vi config.xml
<content src="http://IP:PORT/index.html" />
<allow-navigation href="http:///" />
<preference name="Fullscreen" value="true" />
签名
keytool -genkey -v -keystore release-key.keystore -alias cordova-demo -keyalg RSA -keysize 2048 -validity 10000
vi build.json
{
"android": {
"release": {
"keystore": "release-key.keystore",
"alias": "cordova-demo",
"storePassword": "password",
"password": "password"
}
}
}
禁用缓存
import android.webkit.WebSettings;
import android.webkit.WebView;
@Override
protected void onResume() {
super.onResume();
// Disable caching ..
WebView wv = (WebView) appView.getEngine().getView();
WebSettings ws = wv.getSettings();
ws.setAppCacheEnabled(false);
ws.setCacheMode(WebSettings.LOAD_NO_CACHE);
loadUrl(launchUrl); // launchUrl is the default url specified in Config.xml
}