webview android显示网址 [英] webview android to show url
本文介绍了webview android显示网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用android webview显示url。但是当没有互联网连接时它显示整个网址
喜欢:abc.com不可用。我想要没有互联网时显示网址
I m using android webview to show url.but when there is no internet connection it shows whole url
Like:abc.com not available. I want that url does not show when no internet
推荐答案
你好,
你可以使用以下功能检查互联网连接是否可用。
Hello,
You can use following function to check whether internet connection is available or not.
private boolean isNetAvailable() {
ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = conMgr.getActiveNetworkInfo();
if (null == netInfo)
{
// There are no active networks.
return false;
}
else
return true;
}
您还需要在清单文件中添加以下条目。
You will also require to add following entry in manifest file.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
问候,
Regards,
这篇关于webview android显示网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文