Tag Archives: internet

3,145 views

Check Internet connection Android example

public boolean isConnected() { try { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getActiveNetworkInfo().isConnectedOrConnecting(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e("isConnected", e.getMessage()); Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); return false; }

Posted in Android Examples Code | Tagged , | Comments Off on Check Internet connection Android example