I've bumped into a strange issue - WebView becomes unresponsive when I finish the activity that started the activity with the WebView BUT it doesn't happen on the first launch, only on the consecutive ones and it also happens on Android 6 and 7, newer Android versions seem to handle that gently. The full project which reproduces this can be found here
I have two activities Launcher
class LauncherActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startActivity(Intent(this, MainActivity::class.java))
finish()
}
}
And MainActivity with the WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val webView = findViewById<WebView>(R.id.oauthWebView)
webView.loadUrl("https://semantic-ui.com/examples/login.html")
}
}
When I start the app the first time everything seems okay, but the second time when I open it,
WebView becomes unresponsive, the keyboard is not showing and it happens right after Launcher
onDestroy
If I'm not calling finish
in the LauncherActivity everything is fine.
It looks like finishing LauncherActivity
has some impact on WebView
loading or some other process that's happening under the hood.
It's pretty weird, Logcat is not very helpful either.
Maybe any of you can provide some hint what might be the reason for such behaviour?
Side note: I'm not looking for answers on how to architect my navigation better, I know it can be done differently - I'm curious why WebView is behaving so weird.