H5AdsWebViewClient

@RequiresApi(api = VERSION_CODES.LOLLIPOP)
public final class H5AdsWebViewClient extends WebViewClient


H5 広告リクエストをインターセプトして処理する WebViewClient。これを使用するには、H5 広告リクエストを行うウェブアプリを含む WebView のクライアントとして設定します。

重要: この WebViewClient は複数の WebView に使用できません。H5 広告をサポートする新しい WebView では、必ず新しい H5AdsWebViewClient を使用する必要があります。

コード例:

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);
}

概要

パブリック コンストラクタ

H5AdsWebViewClient(Context context, WebView webView)

H5AdsWebViewClient のコンストラクタ。

パブリック メソッド

void

H5 広告で管理されているすべての広告を破棄します。

void
doUpdateVisitedHistory(WebView view, String url, boolean isReload)
@Nullable WebViewClient

デリゲート WebViewClient を取得します。

void
onFormResubmission(WebView view, Message dontResend, Message resend)
void
void
@RequiresApi(api = VERSION_CODES.M)
onPageCommitVisible(WebView view, String url)
void
void
onPageStarted(WebView view, String url, Bitmap favicon)
void
void
@RequiresApi(api = VERSION_CODES.M)
onReceivedError(
    WebView view,
    WebResourceRequest request,
    WebResourceError error
)
void
onReceivedError(
    WebView view,
    int errorCode,
    String description,
    String failingUrl
)

このメソッドは非推奨です。

void
onReceivedHttpAuthRequest(
    WebView view,
    HttpAuthHandler handler,
    String host,
    String realm
)
void
@RequiresApi(api = VERSION_CODES.M)
onReceivedHttpError(
    WebView view,
    WebResourceRequest request,
    WebResourceResponse errorResponse
)
void
onReceivedLoginRequest(
    WebView view,
    String realm,
    @Nullable String account,
    String args
)
void
onReceivedSslError(
    WebView view,
    SslErrorHandler handler,
    SslError error
)
boolean
@RequiresApi(api = VERSION_CODES.O)
onRenderProcessGone(WebView view, RenderProcessGoneDetail detail)
void
@RequiresApi(api = VERSION_CODES.O_MR1)
onSafeBrowsingHit(
    WebView view,
    WebResourceRequest request,
    int threatType,
    SafeBrowsingResponse callback
)
void
onScaleChanged(WebView view, float oldScale, float newScale)
void
onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg)

このメソッドは非推奨です。

void
void

H5AdsWebViewClient で処理されないメソッドを委任するように WebViewClient を設定します。

@Nullable WebResourceResponse
@Nullable WebResourceResponse

このメソッドは非推奨です。

boolean
boolean
@RequiresApi(api = VERSION_CODES.N)
shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
boolean

このメソッドは非推奨です。

保護されたメソッド

WebViewClient

継承される定数

android.webkit.WebViewClient から
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

継承されるメソッド

android.webkit.WebViewClient から
void
doUpdateVisitedHistory(WebView p, String p1, boolean p2)
void
void
void
void
void
void
void
void
onReceivedHttpAuthRequest(
    WebView p,
    HttpAuthHandler p1,
    String p2,
    String p3
)
void
void
void
boolean
void
onSafeBrowsingHit(
    WebView p,
    WebResourceRequest p1,
    int p2,
    SafeBrowsingResponse p3
)
void
onScaleChanged(WebView p, float p1, float p2)
void

このメソッドは非推奨です。

void
WebResourceResponse
boolean
boolean

パブリック コンストラクタ

H5AdsWebViewClient

public H5AdsWebViewClient(Context context, WebView webView)

H5AdsWebViewClient のコンストラクタ。

パラメータ
Context context

アクティビティまたはアプリのコンテキスト。

WebView webView

この H5AdsWebViewClient に関連付けられる WebView。WebView で JavaScript を有効にする必要があります。

パブリック メソッド

clearAdObjects

public void clearAdObjects()

H5 広告で管理されているすべての広告を破棄します。

注: このメソッドは、H5 以外の AdMob API( や など)によって作成された広告には影響しません。

doUpdateVisitedHistory

public void doUpdateVisitedHistory(WebView view, String url, boolean isReload)

getDelegateWebViewClient

public @Nullable WebViewClient getDelegateWebViewClient()

デリゲート WebViewClient を取得します。

onFormResubmission

public void onFormResubmission(WebView view, Message dontResend, Message resend)

onLoadResource

public void onLoadResource(WebView view, String url)

onPageCommitVisible

@RequiresApi(api = VERSION_CODES.M)
public void onPageCommitVisible(WebView view, String url)

onPageFinished

public void onPageFinished(WebView view, String url)

onPageStarted

public void onPageStarted(WebView view, String url, Bitmap favicon)

onReceivedClientCertRequest

public void onReceivedClientCertRequest(WebView view, ClientCertRequest request)

onReceivedError

@RequiresApi(api = VERSION_CODES.M)
public void onReceivedError(
    WebView view,
    WebResourceRequest request,
    WebResourceError error
)

onReceivedError

public void onReceivedError(
    WebView view,
    int errorCode,
    String description,
    String failingUrl
)

onReceivedHttpAuthRequest

public void onReceivedHttpAuthRequest(
    WebView view,
    HttpAuthHandler handler,
    String host,
    String realm
)

onReceivedHttpError

@RequiresApi(api = VERSION_CODES.M)
public void onReceivedHttpError(
    WebView view,
    WebResourceRequest request,
    WebResourceResponse errorResponse
)

onReceivedLoginRequest

public void onReceivedLoginRequest(
    WebView view,
    String realm,
    @Nullable String account,
    String args
)

onReceivedSslError

public void onReceivedSslError(
    WebView view,
    SslErrorHandler handler,
    SslError error
)

onRenderProcessGone

@RequiresApi(api = VERSION_CODES.O)
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail)

onSafeBrowsingHit

@RequiresApi(api = VERSION_CODES.O_MR1)
public void onSafeBrowsingHit(
    WebView view,
    WebResourceRequest request,
    int threatType,
    SafeBrowsingResponse callback
)

onScaleChanged

public void onScaleChanged(WebView view, float oldScale, float newScale)

onTooManyRedirects

public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg)

onUnhandledKeyEvent

public void onUnhandledKeyEvent(WebView view, KeyEvent event)

setDelegateWebViewClient

public void setDelegateWebViewClient(@Nullable WebViewClient delegate)

H5AdsWebViewClient で処理されないメソッドを委任するように WebViewClient を設定します。

shouldInterceptRequest

public @Nullable WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request)

shouldInterceptRequest

public @Nullable WebResourceResponse shouldInterceptRequest(WebView view, String url)

shouldOverrideKeyEvent

public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event)

shouldOverrideUrlLoading

@RequiresApi(api = VERSION_CODES.N)
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)

shouldOverrideUrlLoading

public boolean shouldOverrideUrlLoading(WebView view, String url)

保護されたメソッド

getDelegate

protected WebViewClient getDelegate()