문제 설명
webview가 검은 색으로 바뀌고 응용 프로그램이 충돌합니다. (webview turns black and application crashes)
내 Android 애플리케이션에 여러 개의 webview가 있습니다. 몇 분 후에 webview를 실행하면 검은색으로 바뀌고 애플리케이션이 충돌합니다.
이것은 webview xml입니다.
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="63dp"
android:visibility="visible" />;
여기에 내 활동에서 webview를 초기화하는 코드가 있습니다.
mywebPage = (WebView) findViewById(R.id.webView);
mywebPage.getSettings().setJavaScriptEnabled(true);
mywebPage.getSettings().setDomStorageEnabled(true);
mywebPage.addJavascriptInterface(this, "Android");
mywebPage.setFocusable(true);
mywebPage.setFocusableInTouchMode(true);
mywebPage.setWebChromeClient(new WebChromeClient() {
public boolean onConsoleMessage(ConsoleMessage cm) {
LogUtil.writeLog(this.getClass(), "WebView " + cm.message() + " ‑‑ From line " + cm.lineNumber() + " of " + cm.sourceId());
return true;
}
});
도움을 주셔서 미리 감사드립니다!
참조 솔루션
방법 1:
Your id in the XML
with the id called in the Activity
is not the same. Try in the activity
to define like this. And as suggestion everytime when you define something you need to start with lowercase. For example : myWebPage
, android:id="@+id/tvInfo"
.
myWebPage = (WebView) findViewById(R.id.Info);
(by Immanuel、Abedin.Zhuniqi)