Ads Intrusion Preventing Engine is a simple library to block ads Intrusion in web dataserver. this code is basicaly stop the ads and remove the html from it and render it again.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency in app level build.gradle file
dependencies {
implementation 'com.github.iAapTeck:Ads-Intrusion-Preventing-Engine:v1.0.1'
}
Inisialize the webview in your activity where you have the webview.
new AdsIntrusionPreventingEninge.init(this).initializeWebView(webView);
Now to block ads intrusion, we need to add this code in the WebViewClient so extentd the WebViewClient for your webview like this and then in the class overide this method.
webView.setWebViewClient(new Browser_home());
private class Browser_home extends WebViewClient {
Browser_home() {}
@SuppressWarnings("deprecation")
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
return AdsIntrusionPreventingEninge.blockAds(view,url) ? AdsIntrusionPrevention.createEmptyResource() :
super.shouldInterceptRequest(view, url);
}
}
Now you can run your app to see if the ads instrusion are blocked. You can always use other webview features and add fetures to the webview.