Code example for ConnectivityManager

Methods: getNetworkInfo

0
		mOnline = false;
 
		ConnectivityManager mCmgr = (ConnectivityManager) context
				.getSystemService(Service.CONNECTIVITY_SERVICE);
 
		NetworkInfo ni = mCmgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		if (ni != null && ni.isConnected()) { /* wifi is on */
			mOnline = true;
		} else { 
			if (mMobile) {
				/* if mobile is active and EDGE or better, we're good */ 
				ni = mCmgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
				if (ni != null && ni.isConnected()) {
					mOnline = (ni.getSubtype() >= TelephonyManager.NETWORK_TYPE_EDGE);
				} 
			} 
		} 
		return mOnline;
	} 
 
	static public boolean updateNotification(Context context) {