public class InternetDetector {
private Context mcontext;
public InternetDetector(Context context) {
this.mcontext = context;
}
public boolean checkMobileInternetConn() {
ConnectivityManager connectivity = (ConnectivityManager) mcontext
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo wifi = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo phe = connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi != null ) {
if (wifi.isConnected()) {
return true;
}
else if (phe.isConnected()){
return true;
}
else{
return false;
}
}
}
return false;
}
}
This deals about whether the device has Internet Connection or not ..Including Wifi.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.