当前位置: 首页>>代码示例>>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;未经允许,请勿转载。