투케이2K

339. (kotlin/코틀린) [Android 13] 웹뷰에서 Console Log 콘솔 로그 확인 방법 (Webview onConsoleMessage) 본문

Kotlin

339. (kotlin/코틀린) [Android 13] 웹뷰에서 Console Log 콘솔 로그 확인 방법 (Webview onConsoleMessage)

투케이2K 2023. 7. 9. 21:28

[개발 환경 설정]

개발 툴 : AndroidStudio

개발 언어 : Kotlin

 

[소스 코드]

            // -----------------------------------------
            // TODO [크롬 클라이언트 설정 실시]
            main_webview!!.webChromeClient = object : WebChromeClient() {

                // TODO [웹 브라우저 콘솔 로그 확인]
                override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
                    S_Log._E_(S_FinalMsg.LOG_Message, arrayOf(
                        "URL :: " + main_webview!!.url.toString(),
                        "message [1] :: " + consoleMessage.message().toString(),
                        "message [2] :: $consoleMessage",
                        "sourceId :: " + consoleMessage.sourceId().toString()
                    ))
                    return super.onConsoleMessage(consoleMessage)
                }

            }
            // -----------------------------------------
 

[결과 출력]

 

E///===========//: ================================================
I/: [LOG :: CLASS PLACE :: com.example.kotlinproject.A_Webview$init_WebView$3.onConsoleMessage(A_Webview.kt:304)]
I/: ----------------------------------------------------
I/: [LOG :: NOW TIME :: 2023-07-09 21:03:26 일요일]
I/: ----------------------------------------------------
I/: [LOG :: DESCRIPTION :: 메시지 확인]
I/: ----------------------------------------------------
I/: [LOG :: URL :: https://m.naver.com/]
I/: ----------------------------------------------------
I/: [LOG :: message [1] :: The resource https://ssl.pstatic.net/sstatic/search/mobile/css/w_new_230706.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.]
I/: ----------------------------------------------------
I/: [LOG :: message [2] :: android.webkit.ConsoleMessage@f1f6df7]
I/: ----------------------------------------------------
I/: [LOG :: sourceId :: https://m.search.naver.com/remote_frame]
E///===========//: ================================================

 


 

반응형
Comments