안드로이드

[Android] WebView Bridge Thread 에러

Zibro 2022. 7. 26. 23:49
728x90
반응형
Only the original thread that created a view hierarchy can touch its views.
A WebView method was called on thread 'javabridge'. All WebView methods must be called on the same thread.

위의 두 에러는 JavaScript에서 Android 메서드를 호출하고자 할 때 사용하는 Bridge에서 Android UI 작업 시 발생하는 에러입니다.

아래와 같이 JavaScript Bridge는 비 UI 스레드입니다.

Bridge Thread

해결방법🤔

WebView의 post() 메서드를 활용해 UI작업을 메인 스레드에서 작업할 수 있도록 해결했습니다.

webView.post(new Runnable() {
	@Oberride
    public void run(){
    	//UI 작업
    }
});
반응형

출처 : https://blog.danggun.net/3334

728x90
반응형