Code example for NetworkInfo

Methods: getTypeName, isConnected

0
 
	@Override 
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo ni = cm.getActiveNetworkInfo();
		if (ni != null && ni.isConnected()) {
			list.isConnected = true;
			list.setTitle("Download Accelerator - Connected to " + ni.getTypeName());
		} else { 
			list.isConnected = false;
			list.setTitle("Download Accelerator - Disconnected");
		} 
	} 
}