package com.samples.network.networkstateinfo;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.widget.TextView;

public class NetworkStateInfoActivity extends Activity {	   
	@Override
    protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    
	    TextView text = (TextView)findViewById(R.id.text);
	    
	    ConnectivityManager cm = (ConnectivityManager)getSystemService(
	    		Context.CONNECTIVITY_SERVICE);
	   
	    NetworkInfo[] ni = cm.getAllNetworkInfo();
	   
	    for (int i = 0; i < ni.length; i++) {
		   	text.append("Type:\t" + ni[i].getTypeName());
	        text.append("\n\tAvailable:\t" + ni[i].isAvailable());
	        text.append("\n\tConnected:\t" + ni[i].isConnected());
		   	text.append("\n\tExtra:\t" + ni[i].getExtraInfo() + "\n");
	   }      
	}
}