Showing posts with label CONNECTIVITY_SERVICE. Show all posts
Showing posts with label CONNECTIVITY_SERVICE. Show all posts

Tuesday, March 18, 2014

Check Internet Connection

ConnectivityManager cn = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

          NetworkInfo nf = cn.getActiveNetworkInfo();

          if (nf != null && nf.isConnected() == true) {

                 Toast.makeText(getApplicationContext(),                                                                      "Internet Connected.", Toast.LENGTH_LONG).show();


          } else {
          
                 Toast.makeText(getApplicationContext(),
                                                                      "No Internet.", Toast.LENGTH_LONG).show();
          }