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 WebView
s. 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);
}
Inherited Constant Summary
Public Constructor Summary
Public Method Summary
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 |
Protected Method Summary
WebViewClient |
Inherited Method Summary
Public Constructors
Public Methods
public void clearAdObjects ()
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
.
public WebViewClient getDelegateWebViewClient ()
Gets the delegate WebViewClient
.
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
public void onReceivedError (WebView view, WebResourceRequest request, WebResourceError error)
public void onReceivedHttpAuthRequest (WebView view, HttpAuthHandler handler, String host, String realm)
public void onReceivedHttpError (WebView view, WebResourceRequest request, WebResourceResponse errorResponse)
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error)
public boolean onRenderProcessGone (WebView view, RenderProcessGoneDetail detail)
public void onSafeBrowsingHit (WebView view, WebResourceRequest request, int threatType, SafeBrowsingResponse callback)
public void onScaleChanged (WebView view, float oldScale, float newScale)
public void setDelegateWebViewClient (WebViewClient delegate)
Sets a WebViewClient
to delegate methods not handled by H5AdsWebViewClient
.