标签:
private static final String TOAST = "toast"; @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Activity activity = this.cordova.getActivity(); if (action.equals("getExtra")) { Intent i = activity.getIntent(); if (i.hasExtra(Intent.EXTRA_TEXT)) { callbackContext.success(i.getStringExtra(Intent.EXTRA_TEXT)); } else { callbackContext.error(""); } return true; }else if (action.equals(TOAST)) { Toast.makeText(cordova.getActivity(), "hello world", Toast.LENGTH_SHORT).show(); } return false; } }
cordova.define("com.myproj.test.ExtraInfo", function(require, exports, module) { var exec = require(‘cordova/exec‘); exports.getExtra = function(success, error) { exec(success, error, "ExtendInfo", "getExtra", []); }; exports.toast = function(content,type) { exec(null, null, "ExtraInfo", "toast", []); }; });
{ "file": "plugins/com.myproj.test/www/ExtendInfo.js", "id": "com.myproj.test.ExtraInfo", "clobbers": [ "ExtendInfo" ] }
我理解的 clobbers里的ExtendInfo就是一会儿在index.html的js当中调用的名称
<script type="text/javascript"> app.initialize(); document.addEventListener("deviceready", fun, false); function fun() { alert("kk"); ExtendInfo.toast(); } </script>
标签:
原文地址:http://www.cnblogs.com/rebeccay/p/4953955.html