i am using a web view in my android app,how can i remove " Web Page not available" from my android app when there is no internet access
質問する
77 次
2 に答える
0
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
このコードは、インターネットがあるかどうかを示しています..インターネットがない場合は、必要に応じてスキップできます..
于 2012-11-08T11:29:59.997 に答える
0
かどうかを確認connection.getResponseCode() == 200
し、静的ページにリダイレクトします。
于 2012-11-08T11:30:32.883 に答える