Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /**
  2. * isNetworkAvailable() TRUE wenn eine Datenverbindung vorhanden ist
  3. *
  4. * @param mixed activity
  5. * @return
  6. */
  7. public static boolean isNetworkAvailable(Activity activity) {
  8. ConnectivityManager connectivity = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
  9. if (connectivity == null) {
  10. return false;
  11. } else {
  12. NetworkInfo[] info = connectivity.getAllNetworkInfo();
  13. if (info != null) {
  14. for (int i = 0; i < info.length; i++) {
  15. if (info[i].getState() == NetworkInfo.State.CONNECTED) {
  16. return true;
  17. }
  18. }
  19. }
  20. }
  21. return false;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement