Code example for ConnectivityManager: Querying Network Reachability

Methods: getActiveNetworkInfo

0
    public static boolean checkNetwork() 
    { 
        boolean state = false;
        final ConnectivityManager conMgr =  (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
		final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
		if (activeNetwork != null && activeNetwork.isConnected()) {
			state = true;
		} else { 
			state = false;
		} 
 
        return state;
    } 
 
    /** 
    * To recieve network state changes 
    */ 
    public static void registerNetworkCheck() 
    { 
        IntentFilter i = new IntentFilter();