I was able to solve it by making following changes to the class:
public class ClientWebView : WebViewClient
{
private Context context;
public ClientWebView(Context context)
{
this.context = context;
}
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
view.LoadUrl(url);
return true;
}
public override void OnPageStarted(WebView view, string url, Bitmap favicon)
{
progressDialog.Show();
if (url.Equals("https://test.com/"))
{
var intent = new Intent(context, typeof(MainActivity));
context.StartActivity(intent);
}
base.OnPageStarted(view, url, favicon);
}
public override void OnPageFinished(WebView view, string url)
{
if (progressDialog != null)
{
progressDialog.Hide();
}
base.OnPageFinished(view, url);
}
public override void OnReceivedError(WebView view, IWebResourceRequest request, WebResourceError error)
{
webView.Visibility = ViewStates.Invisible;
dialog.Show();
base.OnReceivedError(view, request, error);
}
}
and then added following in my oncreate method:
webView.SetWebViewClient(new ClientWebView(this));