> For the complete documentation index, see [llms.txt](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/webad.md).

# WebAd

**package com.intowow\.sdk**

**public class WebAd**

![](https://1252529651-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGU_q6Cp7glylaa3ogy%2F-LHc4r11_LGHRxpg0UtE%2F-LHc5oer3kw8os-Llp7G%2Fweb.png?alt=media\&token=b747466a-4d55-485e-94ee-2383841908c5)

### Overview

Web View Ad format helps you to insert the ad into the web view without latency. User can see varies kinds of ads in web view.

### Characteristics

* Zero latency loading in web view.
* Support image and video.
* Video is mute by default, and can be toggled by clicking it.

## Integration

Before showing the ad on the web view, we need to setup the WebAd object. The WebAd object can help intowow SDK interact with the web view.

### 1. Initialize WebAd

Init the WebAd Object and register the object to the web view.

```java
import com.intowow.sdk.WebAd;

private WebView mWebView = new WebView(context);
private WebAd mWebAd = new WebAd(context);

mWebAd.registerWebView(mWebView);
```

### 2. Check shouldInterceptRequest in WebViewClient

Override the **shouldInterceptRequest** and pass the intowow related url to intowow SDK. Our SDK will return the WebResourceResponse back to the WebView to insert the ad source.

```java
mWebView.setWebViewClient(new WebViewClient() {
 @Override
 public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
     if (request.getUrl() != null && request.getUrl().toString() != null &&
         request.getUrl().toString().indexOf(WebAd.INTOWOW_PREFIX) != -1) {
         WebResourceResponse response = mWebAd.shouldInterceptRequest(view, request);
         if (response != null) {
             return response;
         }
     }
     return super.shouldInterceptRequest(view, request);
 }
});
```

### 3. Destroy WebAd if you no longer need to use it

Please destroy the instance when you no longer need to use it.

```java
if(mWebAd != null) {
    mWebAd.unregisterWebView();
    mWebAd.destroy();
}
```

{% hint style="info" %}

#### Please see the [web](/crystalexpress-documentation-v3-x/web.md) side for further integration detail.

{% endhint %}

{% content-ref url="/pages/-LHfk-gYLDPtrNq03irI" %}
[Web](/crystalexpress-documentation-v3-x/web.md)
{% endcontent-ref %}

## Note:

* Please make sure to new an instance before requesting the ad.

| Public constructors                                                                                                                       |
| ----------------------------------------------------------------------------------------------------------------------------------------- |
| [WebAd(Context context)](/crystalexpress-documentation-v3-x/android-sdk/api-reference/ad/nativead.md#NativeAd)  Instantiates a new webAd. |

| Public methods      |                                                                                                                                                                                                                                                                          |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| void                | [destroy() ](/crystalexpress-documentation-v3-x/android-sdk/api-reference/webad.md#destroy)Release the native ad.                                                                                                                                                        |
| void                | [registerWebView(WebView webview) ](/crystalexpress-documentation-v3-x/android-sdk/api-reference/webad.md#registerwebview)Register web view for interaction.                                                                                                             |
| void                | [unregisterWebView() ](/crystalexpress-documentation-v3-x/android-sdk/api-reference/webad.md#unregisterwebview)Unregister Web view.                                                                                                                                      |
| WebResourceResponse | [shouldInterceptRequest(WebView view, WebResourceRequest request)](/crystalexpress-documentation-v3-x/android-sdk/api-reference/webad.md#shouldinterceptrequest)Pass the request path which related to intowow and will return the webResourceResponse back to web view. |

### WebAd(Context context)

Instantiates a new WebAd.

| Parameters |                       |
| ---------- | --------------------- |
| context    | Context: the context. |

### destroy <a href="#destroy" id="destroy"></a>

void destroy()

Release the WebAd.

### registerWebView

void registerWebView(WebView webview)

Register web view for interaction.

{% hint style="warning" %}
**Please called this function before load the page url.**
{% endhint %}

### unregisterWebView

void unregisterWebView(WebView webview)

Unregister web view when no long use.

### shouldInterceptRequest

WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request)

Pass the request path which related to intowow and return the webResourceResponse back to web view.
