android studio check network connection
//beware that (contextname) is your activity name like if your working on
//activity with name of FirstActivity then instead of (contextname)
//write **FirstActivity.this**.getSystemService...
ConnectivityManager cm =
(ConnectivityManager)contextname.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
//in the end boolean Variable isConnected should hold the Status
//of your network Connection if isConnected is true then you have active network
//otherwise if its false you have no internet Connection