Android examples for Hardware:Device Feature
This Function check Internet is Available or Not in the Android Device ( return true/false).
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /**//from w w w . ja va2s. c o m * This Function check Internet is Available or Not in the Android Device ( * return true/false). * * * Requires Permission: android.permission.ACCESS_NETWORK_STATE See below * for @params. */ public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; } return false; } }