com.tencent.smtt.sdk.WebViewClient Java Examples

The following examples show how to use com.tencent.smtt.sdk.WebViewClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: X5WebViewClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #2
Source File: X5WebViewClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view        The WebView that is initiating the callback.
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
  // Ignore error due to stopLoading().
  if (!isCurrentlyLoading) {
    return;
  }
  LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

  // If this is a "Protocol Not Supported" error, then revert to the previous
  // page. If there was no previous page, then punt. The application's config
  // is likely incorrect (start page set to sms: or something like that)
  if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
    parentEngine.client.clearLoadTimeoutTimer();

    if (view.canGoBack()) {
      view.goBack();
      return;
    } else {
      super.onReceivedError(view, errorCode, description, failingUrl);
    }
  }
  parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #3
Source File: X5WebViewClient.java    From cordova-plugin-x5-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #4
Source File: X5WebViewClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #5
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
private WebViewClient getClient() {

        LogUtils.i(TAG, "getWebViewClient:" + this.mMiddleWrareWebClientBaseHeader);
        DefaultWebClient mDefaultWebClient = DefaultWebClient
                .createBuilder()
                .setActivity(this.mActivity)
                .setClient(this.mWebViewClient)
                .setManager(this.mWebViewClientCallbackManager)
                .setWebClientHelper(this.webClientHelper)
                .setPermissionInterceptor(this.mPermissionInterceptor)
                .setWebView(this.mWebCreator.get())
                .setInterceptUnkownScheme(this.isInterceptUnkownScheme)
                .setSchemeHandleType(this.openOtherAppWays)
                .setCfg(this.mDefaultMsgConfig.getWebViewClientMsgCfg())
                .build();
        MiddleWareWebClientBase header = this.mMiddleWrareWebClientBaseHeader;
        if (header != null) {
            MiddleWareWebClientBase tail = header;
            int count = 1;
            MiddleWareWebClientBase tmp = header;
            while (tmp.next() != null) {
                tail = tmp = tmp.next();
                count++;
            }
            LogUtils.i(TAG, "MiddleWareWebClientBase middleware count:" + count);
            tail.setWebViewClient(mDefaultWebClient);
            return header;
        } else {
            return mDefaultWebClient;
        }

    }
 
Example #6
Source File: MiddleWareWebClientBase.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
MiddleWareWebClientBase(WebViewClient client) {
    super(client);
}
 
Example #7
Source File: X5WebView.java    From cordova-plugin-x5engine-webview with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebViewClient(WebViewClient client) {
    viewClient = (X5WebViewClient)client;
    super.setWebViewClient(client);
}
 
Example #8
Source File: X5WebView.java    From cordova-plugin-x5-tbs with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebViewClient(WebViewClient client) {
  viewClient = (X5WebViewClient) client;
  super.setWebViewClient(client);
}
 
Example #9
Source File: X5WebView.java    From cordova-plugin-x5-webview with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebViewClient(WebViewClient client) {
    viewClient = (X5WebViewClient)client;
    super.setWebViewClient(client);
}
 
Example #10
Source File: X5WebView.java    From x5webview-cordova-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebViewClient(WebViewClient client) {
    viewClient = (X5WebViewClient)client;
    super.setWebViewClient(client);
}
 
Example #11
Source File: MiddleWareWebClientBase.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
@Override
 final void setWebViewClient(WebViewClient webViewClient) {
    super.setWebViewClient(webViewClient);

}
 
Example #12
Source File: WebviewActivity.java    From AndroidFrame with Apache License 2.0 4 votes vote down vote up
private void initWebview() {
    mWebView = findViewById(R.id.webview);
    mBridge = new WebViewJavascriptBridge(this, sHandler, mWebView);
    mWebView.addJavascriptInterface(mBridge, "AndroidWebViewJavascriptBridge");
    WebSettings webSetting = mWebView.getSettings();
    webSetting.setJavaScriptEnabled(true);
    webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
    webSetting.setAllowFileAccess(true);
    webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webSetting.setSupportZoom(true);
    webSetting.setBuiltInZoomControls(true);
    webSetting.setUseWideViewPort(true);
    webSetting.setSupportMultipleWindows(true);
    // webSetting.setLoadWithOverviewMode(true);
    webSetting.setAppCacheEnabled(true);
    // webSetting.setDatabaseEnabled(true);
    webSetting.setDomStorageEnabled(true);
    webSetting.setGeolocationEnabled(true);
    webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
    // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
    webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
    // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
    webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
    String userAgent = webSetting.getUserAgentString() + " " + AGENG_STR
            + AGENG_STR_SUFFIX + "/" + getVersionName() + "/QD"
            + getQudaoName() + "/";
    webSetting.setUserAgentString(userAgent);
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView webView, String s) {
            InputStream fs = WebviewActivity.this.getResources().openRawResource(
                    R.raw.jsbridge_init);
            String jsbridgeInitScript = getLocalText(fs);
            String js1 = "javascript:var evtAndroidJSB = document.createEvent('Event');"
                    + "evtAndroidJSB.initEvent('AndroidWebViewJavascriptBridgeReady', false, false); "
                    + "document.dispatchEvent(evtAndroidJSB);";
            String js2 = "javascript: " + jsbridgeInitScript;
            if (android.os.Build.VERSION.SDK_INT <= 18) {
                mWebView.loadUrl(js1);
                mWebView.loadUrl(js2);
            } else {
                mWebView.evaluateJavascript(js1, null);
                mWebView.evaluateJavascript(js2, null);
            }
            super.onPageFinished(webView, s);
        }
    });
}
 
Example #13
Source File: WebDefaultSettingsManager.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
@Override
public WebListenerManager setWebViewClient(WebView webView, WebViewClient webViewClient) {
    webView.setWebViewClient(webViewClient);
    return this;
}
 
Example #14
Source File: WrapperWebViewClient.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
void setWebViewClient(WebViewClient webViewClient){
    this.mWebViewClient=webViewClient;
}
 
Example #15
Source File: WrapperWebViewClient.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
WrapperWebViewClient (WebViewClient client){
    this.mWebViewClient=client;
}
 
Example #16
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public CommonBuilderForFragment setWebViewClient(@Nullable WebViewClient webChromeClient) {
    this.mAgentBuilderFragment.mWebViewClient = webChromeClient;
    return this;
}
 
Example #17
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public CommonAgentBuilder setWebViewClient(@Nullable WebViewClient webViewClient) {
    this.mAgentBuilder.mWebViewClient = webViewClient;
    return this;
}
 
Example #18
Source File: DefaultWebClient.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public Builder setClient(WebViewClient client) {
	this.client = client;
	return this;
}
 
Example #19
Source File: WebListenerManager.java    From AgentWebX5 with Apache License 2.0 votes vote down vote up
WebListenerManager setWebViewClient(WebView webView, WebViewClient webViewClient);