that_person

Android:QueryingNetworkReachability via http://goo.gl/f561vx

Aug 24th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. public static boolean haveNetworkConnection(Context context) {
  2.     ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  3.     NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
  4.     if(activeNetwork == null) return false;
  5.     return activeNetwork.isConnected();
  6. }
Add Comment
Please, Sign In to add comment