For many application, you have to check internet connection in emulator or in handset.
First In androidmanifest.xml file give the permission of internet given below :
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
</uses-permission>
Now add Internet Connection code given below :