When I tried to implement Chrome Custom Tabs using shouldOverrideUrlLoading()
in webViewClient()
I am getting the following error:
Wrong 1st argument type. Found: 'android.webkit.WebViewClient', required: 'android.app.Activity'
Here is my code - I am using this GitHub repository https://github.com/GoogleChrome/custom-tabs-client.
The error is coming from my usage of the this
keyword.
I am in Fragment, not in Activity
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, Uri.parse(url), new WebviewFallback());
Toast toast = Toast.makeText(getApplicationContext(),
"This is a message displayed in a Toast" + url, Toast.LENGTH_SHORT);
toast.show();
return true;
}
}