Posted By

chrisaiv on 10/12/11


Tagged

android


Versions (?)

Java: Checking Internet Connectivity


 / Published in: Java
 

Need to check if your device is online before sending/getting a request? Here's how.

  1. public boolean isOnline() {
  2. ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  3. return cm.getActiveNetworkInfo().isConnectedOrConnecting();
  4.  
  5. }

Report this snippet  

You need to login to post a comment.