1

How to block google adsense ads in android webview? I have an adsense enabled website and I am creating android webview app for that website. How to block adsense adss in that webview app? please help. Thanks in advance!

Sintu Cr
  • 39
  • 6
  • follow this doc : https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest) – Ram Koti Sep 14 '17 at 11:22

2 Answers2

0

Follow this: Set your custom user-agent to your webview and display "Show advertisements "," Hide advertisements " options on your fron-end based on google.com.ua/… or Pass mobile_app=1 in URL When website open through webview, Then catch mobile_app=1 through GET method in website, Write code in website: if($_GET['mobile_app'] != 1) {// ads of Google}

Amin Pinjari
  • 1,926
  • 2
  • 23
  • 52
  • How to pass mobile_app=1 in url and where I use the Get method. Please expllain – Sintu Cr Sep 14 '17 at 13:01
  • http://www.example.com/? Consider this as your url then add one paramter to this url like this: http://www.example.com/?is_webview=1 Add your server side this code if GET [is_webview] == 1 store is_webview in session, or cookie endif if SESSION [is_webview] != 1 echo ADSENSE_CODE endif – Amin Pinjari Sep 14 '17 at 13:26
0

try to intercept and block the ads url using the callback shouldOverrideUrlLoading and shouldInterceptRequest .