如何区分错误的URL(错误的服务器地址)和离线网络? 在这两种情况下,我都会收到VolleyError的通信,这是“instanceof NoConnectionError”和“instanceof NetworkError”
感谢
答案 0 :(得分:0)
我终于通过问这个来解决它:
public static boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager)
mCtx.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfoconnectivityManager
.getActiveNetworkInfo();
return activeNetworkInfo != null &&
activeNetworkInfo.isConnected();
}