The following code snippet shows how to check if an Android device can connect to Internet.
package com.livrona.picwords.gcm;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class InternetConnectionDetector {

	private Context _context;

	public InternetConnectionDetector(Context context) {
		this._context = context;
	}

	/**
	 * Check all the network connectors
	 * **/
	public boolean canConnectToInternet() {
		ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connectivity != null) {
			NetworkInfo[] info = connectivity.getAllNetworkInfo();
			if (info != null)
				for (int i = 0; i < info.length; i++)
					if (info[i].getState() == NetworkInfo.State.CONNECTED) {
						return true;
					}

		}
		return false;
	}
}