Notice
Recent Posts
Recent Comments
Link
투케이2K
294. (TWOK/ERROR) [Android] RxCachedThreadScheduler WebView methods must be called .. same thread 본문
투케이2K 에러관리
294. (TWOK/ERROR) [Android] RxCachedThreadScheduler WebView methods must be called .. same thread
투케이2K 2025. 2. 4. 19:11[환경 설정 및 설명]
프로그램 : AndroidStudio
설 명 : [Android] RxCachedThreadScheduler WebView methods must be called .. same thread
[설 명]
--------------------------------------------------------------------------
[에러 원인]
--------------------------------------------------------------------------
1. 안드로이드 웹뷰 App To Web 브릿지 통신 및 데이터 전송 시 메인 스레드가 아닌 곳에서 호출 되어 발생하는 이슈
2. 에러 발생 로그 :
W/WebView: java.lang.Throwable: A WebView method was called on thread 'RxCachedThreadScheduler-1'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 2) {2a94c7d} called on null, FYI main Looper is Looper (main, tid 2) {2a94c7d})
at android.webkit.WebView.checkThread(WebView.java:2625)
at android.webkit.WebView.loadUrl(WebView.java:746)
--------------------------------------------------------------------------
--------------------------------------------------------------------------
[해결 방법]
--------------------------------------------------------------------------
1. App To Web 브릿지 통신 및 데이터 전송 시 메인 스레드가 아닌 경우 new Handler(Looper.getMainLooper()) 내에서 데이터 전송하도록 코드 수정
2. 예시 소스 코드 :
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
// ---------------------------------------------
// [App To Web : setLogin 함수 호출]
// ---------------------------------------------
// [Android >> JavaScript 함수 호출]
// ---------------------------------------------
webView.loadUrl("javascript:setLogin('"+S_Preference.getString(getApplication(), S_FinalData.PRE_USER_LOGIN_ID)+"', '"+S_Preference.getString(getApplication(), S_FinalData.PRE_USER_LOGIN_PW)+"')");
}
}, 0);
--------------------------------------------------------------------------
--------------------------------------------------------------------------
[참고 사이트]
--------------------------------------------------------------------------
https://blog.naver.com/kkh0977/223226093224?trackingCode=blog_bloghome_searchlist
--------------------------------------------------------------------------
반응형
'투케이2K 에러관리' 카테고리의 다른 글
Comments