cordova create Demo
cd Demo
cordova platform add ios android
npm install -g plugman
cordova plugin add cordova-plugin-device
cordova plugin rm cordova-plugin-device
plugman create --name MyInfo --plugin_id info --plugin_version 1.0.0
cd MyInfo
plugman platform add --platform_name android
修改(bug)
source-file src=”src/Android/MyMath.java” target-dir=”src/SimpleMath/MyMath”
为:
source-file src=”src/android/MyMath.java” target-dir=”src/SimpleMath”
调用顺序
js 调用 –> cordova.plugins.MyMath.plus(arg0, success, error)
cordova的接口exec –> exec(success, error, “MyMath”, “Plus”, arg0);
调用底层实现各自平台(ios或者Android)下的类MyMath。
12.cordova plugin add ../MyInfo
13.将Demo-->platforms-->android工程导入到Android studio中
14.如果在Demo工程-->www目录下修改了代码,使用cordova prepare
来同步到Android原生工程中
15.报这个错时Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".
将这一段注释掉<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">