public static boolean checkMobileInternetConn(Context _context) { //Create object for ConnectivityManager class which returns network related info
ConnectivityManager connectivity = (ConnectivityManager) _context .getSystemService(Context.CONNECTIVITY_SERVICE); //If connectivity object is not null if (connectivity != null) { //Get network info - WIFI internet access
NetworkInfo info = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI) ; NetworkInfo info1= connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) ; if (info != null || info1!=null) { //Look for whether device is currently connected to WIFI network
if (info.isConnected() || info1.isConnected()) { return true; } } } return false; }
No comments:
Post a Comment