【android】只让本应用程序的webview加载网页而不调用外部浏览器的办法
16lz
2021-01-25
只让本应用程序的webview加载网页,而不调用外部浏览器打开的办法就是:设置WebViewClient,并重写WebViewClient的shouldOverrideUrlLoading方法返回true
mWebView.setWebViewClient(new WebViewClient(){@Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) {// TODO Auto-generated method stubview.loadUrl(url);return true;}});
原因: WebViewClient的shouldOverrideUrlLoading方法的默认实现是直接返回false的:
/** 。。。。。。。 * @param view The WebView that is initiating the callback. * @param url The url to be loaded. * @return True if the host application wants to leave the current WebView * and handle the url itself, otherwise return false. */ public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; }
更多相关文章
- Android(安卓)NDK开发之JNI基础知识
- android 垂直拖动条seekbar
- android中使用BitmapFactory的decodeStream()方法解码图片失败问
- Android(安卓)BindService
- android 通过intent调用短消息的正确方法
- Android(安卓)JiaoZiVideoPlayer源码分析
- Android(安卓)Gesture
- android Binder的使用方式 示例
- 例说 android:mimeType