我正在尝试关闭webview onBackPressed上的广告弹出窗口。但是,它一直在重新加载广告窗口。我正在网站上使用exoclick和juicyads popunders。
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
WebView view = findViewById(R.id.webview);
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
view.setSystemUiVisibility(uiOptions);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setDomStorageEnabled(true);
view.getSettings().setSupportMultipleWindows(true);
view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
//view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
view.setWebViewClient(new WebViewClient() {
view.loadUrl(url);
return false;
});
view.loadUrl("https://example.com");
}
@Override
public void onBackPressed() {
WebView view = findViewById(R.id.webview);
if (view.canGoBack()) {
view.goBack();
return;
} else {
moveTaskToBack(true);
}
}
}