Java tutorial
//package com.java2s; //License from project: LGPL import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /** * checks if there is network connection available * @param currentActivity * @return */ public static boolean isMobileInternetAvailable(Activity currentActivity) { final ConnectivityManager connectivityManager = (ConnectivityManager) currentActivity .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { if (networkInfo.isConnected()) { return true; } } } return false; } }