I have very basic app with a webview. It works perfectly on my samsung phone. But on other android device it works strange. When I run app for the first time webview loads page as expected. Then I deploy once more app from Android Studio (the app has to be in foreground at this moment Using Shift+F10) it does not load web content but displays just blank screen. Then when I put the app to background or kill it and deploy using Android Studio again web page is loading fine.
All this is steadily reproducible on this device. It is important for me to figure out why I have this issue on this device.
I have setup WebViewClient
and WebChromeClient
and can track progress.
webView.setWebViewClient(mWebViewClient)
webView.setWebChromeClient(mWebChromeClient)
override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
Timber.tag(TAG).i(
"Request intercept. Url: %s, method: %s, isformainframe: %b, headers: %s",
request.url,
request.method,
request.isForMainFrame,
request.requestHeaders
)
val response = super.shouldInterceptRequest(view, request)
if (response == null) {
Timber.tag(TAG)
.i("Response intercept. Response object is null")
} else {
Timber.tag(TAG).i(
"Response intercept. Status: %d, Response phrase: %s, headers: %s",
response.statusCode,
response.reasonPhrase,
response.responseHeaders
)
}
return response
}
override fun onProgressChanged(view: WebView, progress: Int) {
Timber.tag(TAG).i("Progress: %d", progress)
}
and this is what I have in my log
Request intercept. Url: https://mywebsite.com
Response intercept. Response object is null
Progress: 10