关闭WebView上的广告弹出窗口无法在BackPressed上运行

时间:2019-02-11 09:46:48

标签: java android webview

我正在尝试关闭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);
    }
}

}

0 个答案:

没有答案