Cordova常用操作

2016-11-22  本文已影响58人  bluexiii

安装

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
}
上一篇 下一篇

猜你喜欢

热点阅读