Code example for NetworkInfo

Methods: getType, isAvailable, isConnected

0
		ConnectivityManager connectivityManager = (ConnectivityManager)
			TiApplication.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connectivityManager != null) {
			try { 
				NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
				if(ni != null && ni.isAvailable() && ni.isConnected()) {
					type = ni.getType();
				} else { 
					type = -2 /*None*/;
				} 
			} catch (SecurityException e) {
				Log.w(TAG, "Permission has been removed. Cannot determine network type: " + e.getMessage());
			} 
		} 
 
		return type;
	} 
 
	private static String networkTypeToTypeName(int type)
	{ 
		switch(type)