I\'m getting a HttpResponse from a server when checking if a username or password is correct.
When I load the url in a webview I want
Just wanna throw another way how this can be done. Not saying it is the best, but it is a way. You can use JavaScript to set cookies as well. Just override onPageFinished in WebViewClient
new WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
val javascript = """document.cookie = "key=$value""""
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
view.evaluateJavascript(javascript) { s -> Timber.d("Inject: %s", s) }
} else {
view.loadUrl("javascript:" + javascript, null)
}
}
}
One thing with this approach: you will have to reload the webView. If anyone knows how to fix that, please comment.