android 拦截h5方法,android
android - webview 拦截资源的几个方法和特点
2017-08-12 18:27
访问量: 2060
分类:
技术
看下面的代码,就可以看出端倪来了
onPageStarted, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是====
shouldInterceptRequest, 触发的url是====.c4ea2db.png
shouldInterceptRequest, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是=====android&language=en
public class MyWebViewClient extends WebViewClient {
// 在上面log中没有看到, 貌似也是可以拦截的..... 需要进一步搜集日志
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "shouldOverrideUrlLoading, 触发的url是====" + url);
//FIXME 姜瑶确认下,这里是否有用.
// view.loadUrl(appendParameters(url));
return false;
}
/**
* 触发的都是基本的URL页面(无法拦截vuejs内的跳转)
*/
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.d(TAG, "onPageStarted, 触发的url是====" + url);
super.onPageStarted(view, url, favicon);
}
拦截到的, 是所有的URL(除了 正常的Url 还包括图片,js, css)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
Log.d(TAG, "shouldInterceptRequest, 触发的url是====" + url);
if(url.contains("__webpack_hmr")) {
Log.d(TAG, "return empty response on __webpack_hmr");
return new WebResourceResponse(null,null, null);
}
android 拦截h5方法,android
android - webview 拦截资源的几个方法和特点
2017-08-12 18:27
访问量: 2060
分类:
技术
看下面的代码,就可以看出端倪来了
onPageStarted, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是====
shouldInterceptRequest, 触发的url是====.c4ea2db.png
shouldInterceptRequest, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是====@3x.png
shouldInterceptRequest, 触发的url是=====android&language=en
shouldInterceptRequest, 触发的url是=====android&language=en
public class MyWebViewClient extends WebViewClient {
// 在上面log中没有看到, 貌似也是可以拦截的..... 需要进一步搜集日志
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "shouldOverrideUrlLoading, 触发的url是====" + url);
//FIXME 姜瑶确认下,这里是否有用.
// view.loadUrl(appendParameters(url));
return false;
}
/**
* 触发的都是基本的URL页面(无法拦截vuejs内的跳转)
*/
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.d(TAG, "onPageStarted, 触发的url是====" + url);
super.onPageStarted(view, url, favicon);
}
拦截到的, 是所有的URL(除了 正常的Url 还包括图片,js, css)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
Log.d(TAG, "shouldInterceptRequest, 触发的url是====" + url);
if(url.contains("__webpack_hmr")) {
Log.d(TAG, "return empty response on __webpack_hmr");
return new WebResourceResponse(null,null, null);
}