ppamorim

Untitled

Aug 26th, 2014
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. //THIS:
  2.    
  3.     public boolean verifyInternetConnection(Context context) {
  4.         try {
  5.             Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com");
  6.             int returnVal = p1.waitFor();
  7.             boolean reachable = (returnVal==0);
  8.             return reachable;
  9.         } catch (Exception e) {
  10.             // TODO Auto-generated catch block
  11.             e.printStackTrace();
  12.         }
  13.         return false;
  14.     }
  15.    
  16.     //TO THIS:
  17.  
  18.     public boolean verifyInternetConnection(Context context) {
  19.         try {
  20.             return (java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com").waitFor()==0);
  21.         } catch (Exception e) {
  22.             e.printStackTrace();
  23.         }
  24.         return false;
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment