I'm trying to use custom WebChromeClient, but for some URL's in android marshmallow and nougat it show's me below error in logcat and don't load URL, but it's working fine for pre marshmallow.
The error:
W/cr_AwContentsClient: Denied starting an intent without a user gesture
What is the meaning the error? How should I handle it?
The webview:
@SuppressLint("SetJavaScriptEnabled")
public class MyWebView extends BaseWebView {
public BrowserWebView(Context context, AttributeSet attrs) {
super(context, attrs);
getSettings().setJavaScriptEnabled(true);
setWebChromeClient(new WebChromeClient());
}
}
The activity :
public class MyActivity extends Activity {
private MyWebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_browser);
webView = (MyWebView) findViewById(R.id.my_web_view);
webView.loadUrl("https://.../");
}
@Override
public void onBackPressed() {
// Check if the key event was the Back button and if there's history
if (webView != null && webView.canGoBack()) {
webView.goBack();
return;
}
super.onBackPressed();
}
}
Activity layout XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.activity.MyActivity">
<com.test.MyWebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/my_web_view"/>
</RelativeLayout>