js调用android时出错
Uncaught Error: Java exception was raised during method invocation
,这是js代码:
window.SearchActivity.getClickData();
,这是Android代码:
mAtlasWebView.addJavascriptInterface(new SearchActivity(), "SearchActivity");
@JavascriptInterface
public void getClickData() {
String mSearchText = mSearchEdit.getText().toString().trim();
mvpPresenter.getClickData(mSearchText, 1);
}
最佳答案
只需将错误处理程序添加到Java Value:
public void getClickData() {
try {
String mSearchText = mSearchEdit.getText().toString().trim();
mvpPresenter.getClickData(mSearchText, 1);
} catch (Exception e) {}
}