Aditya
Aditya

Reputation: 425

What is "WebViewClient"?

I was learning about webview in android when I came across this code: webView.setWebViewClient(new WebViewClient());

My question is what is WebViewClient and whether we can pass another activity context to this?

Upvotes: 1

Views: 1464

Answers (1)

Ahmad Sattout
Ahmad Sattout

Reputation: 113

WebViewClient is the object responsible for most the actions inside a WebView.

JavaScript enabled, security, routing, etc.

You can make a custom one, as well as use a Chrome one.

So no, you cannot pass an Activity as a WebViewClient, they are 2 different things. If you're looking to open an activity on some URL click, use shouldOverrideUrlLoading inside your custom WebViewClient.

Upvotes: 1

Related Questions