private boolean checkIfNetworkConnected() {
boolean result = false;
ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info=connManager.getActiveNetworkInfo();
if (info == null || !info.isConnected()) {
result = false;
} else {
if (!info.isAvailable()) {
result =false;
} else {
result = true;
}
}
return result;
}
Reference:
Android 偵測網路是否連線
No comments:
Post a Comment
You can leave any question here and I will make a response to you ASAP. :D