A WebViewClient
that intercepts and handles H5 ad requests. To use this, set this as the client of the
WebView that contains the web apps that will be making H5 ad requests.
IMPORTANT: This WebViewClient cannot be used for multiple WebViews. Every
new WebView that will support H5 ads must use a new
H5AdsWebViewClient.
Example code:
public void onCreate(Bundle savedInstanceState) {
...
// Initialize early to reduce latency on the session's first ad request.
MobileAds.initialize(this);
WebView myWebView = findViewById(R.id.my_webview);
// JavaScript must be enabled.
WebSettings settings = myWebView.getSettings();
settings.setJavaScriptEnabled(true);
H5AdsWebViewClient h5Client = new H5AdsWebViewClient(this, myWebView);
// (Optional) any existing WebViewClient
WebViewClient myClient = ...;
h5Client.setDelegateWebViewClient(myClient);
webView.setWebViewClient(h5Client);
}
| void |
clearAdObjects()
Destroys all ads being managed by H5 ads.
|
| void | |
| WebViewClient |
getDelegateWebViewClient()
Gets the delegate
WebViewClient.
|
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| void | |
| boolean | |
| void |
onSafeBrowsingHit(WebView view,
WebResourceRequest
request, int threatType, SafeBrowsingResponse callback)
|
| void |
onScaleChanged(WebView view,
float oldScale, float newScale)
|
| void | |
| void | |
| void |
setDelegateWebViewClient(WebViewClient
delegate)
Sets a
WebViewClient
to delegate methods not handled by H5AdsWebViewClient.
|
| WebResourceResponse | |
| WebResourceResponse | |
| boolean | |
| boolean | |
| boolean |
| WebViewClient |
Destroys all ads being managed by H5 ads.
Note: This method has no effect on any ads created by the non-H5 AdMob API, such as
InterstitialAd
and RewardedAd.
Gets the delegate WebViewClient.
Sets a WebViewClient
to delegate methods not handled by H5AdsWebViewClient.