當前位置: 首頁>>代碼示例>>Java>>正文


Java WebResourceRequest.getUrl方法代碼示例

本文整理匯總了Java中android.webkit.WebResourceRequest.getUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java WebResourceRequest.getUrl方法的具體用法?Java WebResourceRequest.getUrl怎麽用?Java WebResourceRequest.getUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebResourceRequest的用法示例。


在下文中一共展示了WebResourceRequest.getUrl方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldInterceptRequest

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
	Uri url = request.getUrl();
	if ("https://www.fengshihao.com/user.js".indexOf(url.toString()) == 0) {
		final WebResourceResponse userjs = new WebResourceResponse("text/javascript", "UTF-8",
			new ByteArrayInputStream("console.log('hello user js');".getBytes()));
		return userjs;
	}
	return super.shouldInterceptRequest(view, request);
}
 
開發者ID:fengshihao,項目名稱:WebPager,代碼行數:12,代碼來源:PagerWebViewClient.java

示例2: shouldInterceptRequest

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
    if (request != null && request.getUrl() != null) {
        try {
            if (!GlobalConfig.isExcludeHost(request.getUrl().getHost())) {
                return getResponseFromUrl(new URL(request.getUrl().toString()));
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:15,代碼來源:ProbeWebClient.java

示例3: shouldInterceptRequest

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
    String url = null != webResourceRequest.getUrl() ? webResourceRequest.getUrl().toString() : null;
    if (!TextUtils.isEmpty(url) && url.startsWith(LOCAL_FILE_SCHEMA)) {
        return getLocalResource(url);
    }

    if (null != _webViewDelegate && null != _webViewDelegate.get()) {
        return _webViewDelegate.get().shouldInterceptRequest(webView, webResourceRequest);
    }
    return super.shouldInterceptRequest(webView, webResourceRequest);
}
 
開發者ID:luffyjet,項目名稱:WebViewJavaScriptBridge,代碼行數:14,代碼來源:WebViewJavaScriptBridge.java

示例4: shouldOverrideUrlLoading

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    Uri url = request.getUrl();
    if (url != null && url.toString().startsWith("htyridapp://")) {
        Intent intent = new Intent();
        intent.setData(Uri.parse(url.toString()));
        startActivity(intent);
        return true;
    }
    return super.shouldOverrideUrlLoading(view, request);
}
 
開發者ID:BaoBaoJianqiang,項目名稱:HybridForAndroid,代碼行數:12,代碼來源:WebViewActivity.java

示例5: shouldOverrideUrlLoading

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    if (request.getUrl().getHost().length() == 0) {
        return false;
    }

    Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());
    view.getContext().startActivity(intent);
    return true;
}
 
開發者ID:lordoftheflies,項目名稱:wonderjameeee,代碼行數:11,代碼來源:AppWebViewClients.java

示例6: shouldOverrideUrlLoading

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
// Force links to be opened inside WebView and not in Default Browser
// Thanks http://stackoverflow.com/a/33681975/1815624
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    Uri uri = request.getUrl();
    if (uri.getScheme().equals("market")) {
        Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(marketIntent);
        return true;
    }

    view.loadUrl(request.getUrl().toString());
    return super.shouldOverrideUrlLoading(view, request);
}
 
開發者ID:sazid,項目名稱:Browse,代碼行數:16,代碼來源:MainActivity.java

示例7: shouldOverrideUrlLoading

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
  Uri link = request.getUrl();
  return handleUri(link);
}
 
開發者ID:azmedien,項目名稱:kolibri-android,代碼行數:7,代碼來源:KolibriWebView.java

示例8: shouldInterceptRequest

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@Override
public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) {
    if (!blockingEnabled) {
        return super.shouldInterceptRequest(view, request);
    }

    final Uri resourceUri = request.getUrl();

    // shouldInterceptRequest() might be called _before_ onPageStarted or shouldOverrideUrlLoading
    // are called (this happens when the webview is first shown). However we are notified of the URL
    // via notifyCurrentURL in that case.
    final String scheme = resourceUri.getScheme();

    if (!request.isForMainFrame() &&
            !scheme.equals("http") && !scheme.equals("https")) {
        // Block any malformed non-http(s) URIs. WebView will already ignore things like market: URLs,
        // but not in all cases (malformed market: URIs, such as market:://... will still end up here).
        // (Note: data: URIs are automatically handled by WebView, and won't end up here either.)
        // file:// URIs are disabled separately by setting WebSettings.setAllowFileAccess()
        return new WebResourceResponse(null, null, null);
    }

    // WebView always requests a favicon, even though it won't be used anywhere. This check
    // isn't able to block all favicons (some of them will be loaded using <link rel="shortcut icon">
    // with a custom URL which we can't match or detect), but reduces the amount of unnecessary
    // favicon loading that's performed.
    final String path = resourceUri.getPath();
    if (path != null && path.endsWith("/favicon.ico")) {
        return new WebResourceResponse(null, null, null);
    }

    final UrlMatcher matcher = getMatcher(view.getContext());

    // Don't block the main frame from being loaded. This also protects against cases where we
    // open a link that redirects to another app (e.g. to the play store).
    if ((!request.isForMainFrame()) &&
            currentPageURL != null &&
            matcher.matches(resourceUri, Uri.parse(currentPageURL))) {
            // Bandaid for issue #26: currentPageUrl can still be null, and needs to be investigated further.
        if (callback != null) {
            callback.countBlockedTracker();
        }
        return new WebResourceResponse(null, null, null);
    }

    return super.shouldInterceptRequest(view, request);
}
 
開發者ID:mozilla-mobile,項目名稱:focus-android,代碼行數:48,代碼來源:TrackingProtectionWebViewClient.java

示例9: shouldOverrideUrlLoading

import android.webkit.WebResourceRequest; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    final Uri uri = request.getUrl();
    return handleUri(view, uri);
}
 
開發者ID:livechat,項目名稱:chat-window-android,代碼行數:7,代碼來源:ChatWindowView.java


注:本文中的android.webkit.WebResourceRequest.getUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。