/*** js接口*/final class JavaScriptInterface {JavaScriptInterface() {}/*** This is not called on the UI thread. Post a runnable to invoke* loadUrl on the UI thread.*/public void showCity() {mHandler.post(new Runnable() {public void run() {new MyApplication().getCity(getActivity().getApplicationContext());String city=MyApplication.city;// String city=getCity();mWebView.loadUrl("javascript:js_showCity(" + city + ")");// mWebView.loadUrl("javascript:js_showCity()");}});}}
一开始,下面这行死活都没反应,把参数传到js里面去,弹出来未定义啊,后来找了很久,原来是忘记写分号了。