当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);
}
答案 0 :(得分:0)
只需将错误处理程序添加到Java void:
public void getClickData() {
try {
String mSearchText = mSearchEdit.getText().toString().trim();
mvpPresenter.getClickData(mSearchText, 1);
} catch (Exception e) {}
}
答案 1 :(得分:0)
最佳和快速的解决方案:在javascript中使用try {}进行环绕;
答案 2 :(得分:0)
您不能在界面方法中触摸视图。如果需要,可以在主线程上运行。检查以下代码:
!pip install opencv-python==3.4.2.17
!pip install opencv-contrib-python==3.4.2.17
import cv2